Skip to main content
Glama

LLM chat completion

llm_chat

Get a reply from any AIMLAPI language model (the model parameter selects it) to a list of chat messages: text, code, reasoning, image understanding for vision models, and function calling with your own tools. For embeddings use embeddings_create; for images, video or music use image_generate, video_generate or audio_generate. Billed to your AIMLAPI balance at the model's price (see model_get). Returns the complete reply: content, role, finish_reason, model, usage (token counts) and tool_calls (the functions the model asked to call, or null); with n > 1 also choices, every reply with its own index, content, finish_reason and tool_calls. A reply that takes longer than about two minutes returns a job_id with status "processing" instead: fetch the reply with job_result.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "model": "<model>",
      "messages": "<messages>"
    },
    "name": "llm_chat"
  }
}

Input Schema

NameRequiredDescriptionDefault
nNoHow many alternative replies the model generates (default 1). With n > 1 the tool returns every reply in `choices`, the first one also in `content`; every reply is billed. A model whose card does not list n returns one reply.
seedNoAn integer for best-effort repeatable sampling: the same seed, model and parameters tend to give the same reply. Not every model supports it, and none guarantees it.
stopNoA string, or a list of strings, at which the model stops writing; the stop text itself is not included in the reply.
modelYesAIMLAPI model id or alias, e.g. "gpt-5" or "claude-opus-4-8". Find ids with models_search, models_list or jev_model_search.
toolsNoFunctions the model may ask to call, in OpenAI format: [{ "type": "function", "function": { "name": "…", "description": "…", "parameters": { JSON Schema } } }]. The model does not run them: its calls come back in `tool_calls`, and you send each result back as a { "role": "tool", "tool_call_id": "…", "content": "…" } message. These are your own functions, not AIMLAPI Agent Tools (tools_run). Only for models with the `tools` capability.
top_pNoNucleus sampling, 0–1: the model picks only among the most likely tokens whose probabilities add up to top_p (0.1 = the top 10%). Omit it for the model default.
streamNoHow the gateway reads the reply from the model: as a stream (true, the default) or in one response (false). This tool returns the complete reply either way; it does not stream to you.
messagesYesOpenAI-style chat messages, oldest first; each is an object like { "role": "user"|"assistant"|"system"|"tool", "content": "…" }. For a model with the `vision` capability, `content` can be an array of parts such as { "type": "image_url", "image_url": { "url": "https://…" } }.
providerNoPin the request to one upstream provider of the model, e.g. "openai" or "google": only that provider is tried, with no fallback to others, and a parameter it does not support is an error instead of being dropped. Omit it (or "auto") to let AIMLAPI use the primary provider and fall back to others. A provider the model does not have is an error that lists the available ones.
max_tokensNoMost tokens the model may generate — the older OpenAI name of the limit, kept for compatibility. Same limit as max_completion_tokens: AIMLAPI sends the value under whichever name the provider expects, so the two fields set the same limit; on reasoning models it also covers the hidden reasoning tokens. Set one; if both are set, max_completion_tokens wins.
temperatureNoSampling temperature, 0–2: higher gives more varied replies, lower more focused and repeatable ones. Omit it for the model default; set temperature or top_p, not both.
tool_choiceNoWhether the model calls one of `tools`: "auto" (the default with tools — the model decides), "none", "required" (it must call one), or { "type": "function", "function": { "name": "…" } } to force that function.
response_formatNoReply format. { "type": "json_object" } asks for valid JSON; { "type": "json_schema", "json_schema": { "name": "…", "schema": { … }, "strict": true } } asks for JSON that matches the schema. Only for models with the `structured_output` capability; omit it for plain text.
presence_penaltyNo-2 to 2. Positive values lower the chance of any token that has already appeared, which nudges the model toward new topics. Default 0.
reasoning_effortNoHow much a model with the `reasoning` capability thinks before answering: "none", "minimal", "low", "medium", "high", "xhigh" or "max" — more effort is slower and uses more (billed) tokens. Each model accepts its own subset (some have no "none"), and a level the model does not accept is an error. A model without reasoning ignores it, unless `provider` is set.
frequency_penaltyNo-2 to 2. Positive values lower the chance of a token the more often it has already appeared, which reduces word-for-word repetition. Default 0.
max_completion_tokensNoMost tokens the model may generate — the newer OpenAI name of the limit, preferred. Same limit as max_tokens: AIMLAPI sends the value under whichever name the provider expects, so the two fields set the same limit; on reasoning models it also covers the hidden reasoning tokens. Set one; if both are set, max_completion_tokens wins.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations only declare readOnly=false, openWorld=true, idempotent=false, destructive=false; the description goes well beyond by disclosing billing against the AIMLAPI balance at the model's price, that stream=true is a gateway detail and the tool never streams to the caller, and the ~2 minute timeout that returns a `job_id` with status "processing" retrievable via job_result. Those are exactly the operational surprises an agent needs warned about for a paid, potentially slow call.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the core action, then alternatives, then cost, then return shape and the long-request fallback — a sensible order with no filler sentences. It is dense and long, but given 17 parameters and no output schema, nearly every clause carries information an agent would otherwise have to discover at runtime.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 17-parameter, nested-object, open-world generation tool with no output schema, the description supplies the return contract (`content`, `role`, `finish_reason`, `model`, `usage`, `tool_calls`, plus per-reply `choices` when n > 1) and the async fallback path. Nothing essential to correct invocation is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% and the parameter docs are unusually rich (n, tools, provider, max_tokens vs max_completion_tokens, reasoning_effort all self-explanatory), so the baseline is 3. The description adds little beyond the schema: it notes `model` selects the model and that `n` > 1 produces per-reply `choices`, both of which the schema already states verbatim.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb+resource: "Get a reply from any AIMLAPI language model ... to a list of chat messages," then enumerates the modalities it covers (text, code, reasoning, vision, function calling). It explicitly names the sibling tools that serve adjacent purposes, so an agent can separate this from embeddings_create, image_generate, video_generate and audio_generate without opening a schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit routing is given for the common confusions: embeddings go to embeddings_create, media generation to image/video/audio_generate, pricing to model_get, and over-two-minute requests to job_result. Both the when-to-use-this and when-to-use-something-else conditions are stated, not merely implied.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources