Ollama Chat client routes /api/chat → 3 backend protocols |
/api/chat Ollama → Ollama Transparent |
OllamaChatRequestDecoder performs capability inspection; OllamaChatProviderRequestAdapter clones the original JSON; OllamaChatWireResponseWriter keeps NDJSON records in the Ollama dialect. |
Unknown request fields, messages, tools, options, format, and unknown JSON response fields are retained. Malformed upstream NDJSON records are forwarded raw. |
Only gateway-owned fields are rewritten: virtual model → physical model upstream, physical model → virtual model downstream; stream is normalized; missing keep_alive receives the request/provider default. |
No known Ollama field is intentionally dropped on this route. Unknown fields make an Ollama-native backend preferred; if none is available, the request may use a documented translated subset. Valid JSON may be reserialized. |
temperature, top_p, top_k, num_predict, num_ctx, repeat_penalty, and think are hard-overridden when configured. |
/api/chat Ollama → OpenAI Chat Translated |
OllamaChatRequestDecoder → GatewayChatRequest → OpenAiChatProviderRequestAdapter. The response reverses through OpenAiChatProviderResponseDecoder and OllamaChatClientResponseWriter. |
Message roles/text, function definitions, function calls/results, streaming intent, temperature, top-p, token limit, images, structured format, and token usage survive when representable. |
images[] → OpenAI image_url data parts; num_predict → max_tokens; think → chat_template_kwargs.enable_thinking; Ollama tool calls and responses are rebuilt as OpenAI tools and back again. |
top_k, num_ctx, repeat_penalty, and keep_alive have no OpenAI Chat mapping. Unknown Ollama controls prefer a native backend but are omitted when this translation path is the only eligible route. |
OpenAI target fields temperature, top_p, and max_tokens use VM values when set. VM Thinking overrides the translated client value. |
/api/chat Ollama → Responses Translated |
OllamaChatRequestDecoder → canonical messages/items → OpenAiResponsesProviderRequestAdapter. Typed Responses Items/events are decoded and rebuilt as Ollama JSON/NDJSON. |
Roles, text, system/developer instructions, images, function tools, function calls/results, temperature, top-p, token limit, structured format, stream, reasoning output, finish state, and usage. |
System messages → instructions; messages → Responses input Items; images → input_image; num_predict → max_output_tokens; format → text.format; function tool shapes are flattened. |
Ollama top_k, num_ctx, repeat_penalty, keep_alive, and boolean think are not encoded into Responses. Responses-native tools cannot be requested from the Ollama dialect. |
VM Temperature, TopP, and NumPredict override temperature, top_p, and max_output_tokens. Other VM sampling fields are not applicable. |
OpenAI Chat Completions client routes /v1/chat/completions → 3 backend protocols |
/v1/chat/completions OpenAI Chat → Ollama Translated |
OpenAiChatRequestDecoder → GatewayChatRequest → OllamaChatProviderRequestAdapter. Ollama response records are decoded into canonical events and emitted as Chat Completion JSON/SSE. |
Roles/text, data-URI images, function tools/calls/results, temperature, top-p, token limit, reasoning text, structured output intent, stream, finish reason, and usage. |
OpenAI content parts → Ollama content + images[]; max_tokens/max_completion_tokens → num_predict; reasoning_effort → boolean think; response_format → Ollama format. |
Remote image URLs have no portable Ollama-native representation; base64/data-URI is the verified conversion. Chat-only controls such as penalties/logprobs/seed prefer a Chat backend and are omitted when Ollama is the only eligible route. |
All Ollama VM controls apply: temperature, top_p, top_k, num_predict, num_ctx, repeat_penalty, and think. Ollama-only values may therefore be injected even though the client dialect cannot express them. |
/v1/chat/completions OpenAI Chat → OpenAI Chat Transparent |
OpenAiChatRequestDecoder inspects capabilities; the provider adapter clones the source JSON; OpenAiChatWireResponseWriter forwards Chat JSON/SSE while observing text, reasoning, tools, and usage. |
Unknown request fields, message/content extensions, response_format, reasoning_effort, vendor fields, unknown response fields, null values, and unrecognized SSE lines remain in the Chat dialect. |
Model identity is masked in both directions; stream is normalized; streaming requests merge stream_options.include_usage=true; null message content is normalized to an empty string. |
No known Chat field is intentionally dropped on this route. Unknown/Chat-only fields prefer a Chat Completions backend, with semantic translation as fallback when no matching backend is available. Valid JSON may be reserialized. |
VM Temperature, TopP, NumPredict, and Thinking override their target fields. Existing nested chat_template_kwargs members are preserved around enable_thinking. |
/v1/chat/completions OpenAI Chat → Responses Translated |
OpenAiChatRequestDecoder → canonical IL → OpenAiResponsesProviderRequestAdapter. Responses output Items/events return through the Responses decoder and Chat client writer. |
Roles/text, images, function tools/calls/results, temperature, top-p, maximum output tokens, reasoning effort/output, structured output, streaming, finish reason, and usage. |
System/developer messages → instructions; messages → input Items; function schemas are flattened; named tool_choice.function.name → Responses tool_choice.name; max_completion_tokens → max_output_tokens; response_format → text.format. |
chat_template_kwargs.enable_thinking has no Responses mapping. Chat-only controls prefer a Chat backend and are omitted on fallback. Responses annotations, citations, and noncanonical output Items cannot be reconstructed in a Chat Completion response. |
VM Temperature, TopP, and NumPredict override Responses target fields. VM Thinking, TopK, NumCtx, and RepeatPenalty are not Responses controls. |
OpenAI Responses client routes /v1/responses → 3 backend protocols · native state passthrough |
/v1/responses Responses → Ollama Translated subset |
OpenAiResponsesRequestDecoder → canonical IL → OllamaChatProviderRequestAdapter. Ollama output becomes typed Responses Items and typed SSE events. |
Instructions, message Items, text, images, function calls/results, function tool definitions, temperature, top-p, output-token limit, reasoning effort/output, structured format, stream, finish reason, and usage. |
instructions → system message; input_text/input_image → Ollama content/images; max_output_tokens → num_predict; reasoning.effort → think; text.format → format; response events are synthesized with stable output indexes. |
previous_response_id, conversation, store:true, background:true, native tools, and unknown Items require a Responses backend. Stateless representable requests fall back to translation. |
All Ollama VM controls apply and override translated values: sampling, context, repeat penalty, token limit, and thinking. Ollama-only DB controls may be injected. |
/v1/responses Responses → OpenAI Chat Translated subset |
OpenAiResponsesRequestDecoder → canonical IL → OpenAiChatProviderRequestAdapter. Chat completions/chunks are decoded and emitted as Responses JSON/typed SSE. |
Instructions, text/images, function tools/calls/results, temperature, top-p, token limit, reasoning effort/output, structured output, stream, finish state, and usage. |
Input Items → Chat messages; instructions → system message; Responses function tool/choice shapes → Chat wrappers; max_output_tokens → max_tokens; reasoning.effort → reasoning_effort; text.format → response_format. |
State/background requests require a Responses backend. Native Responses tools and unknown Items also require Responses. Metadata and unknown top-level controls prefer Responses and are omitted on fallback. Responses-only annotations/citations cannot be recreated from Chat output. |
VM Temperature, TopP, NumPredict, and Thinking override Chat target controls; Chat-only VM thinking is injected through chat_template_kwargs. |
/v1/responses Responses → Responses Transparent, state-aware |
The request adapter deep-clones the original Responses JSON. OpenAiResponsesWireResponseWriter preserves unknown output Items and SSE event names/data/comments/id/retry without passing the payload through canonical IL. |
Unknown top-level and nested request fields, native tools, metadata, future Items, annotations, citations, unknown response fields, future SSE event types, and JSON/non-JSON event data are retained. |
Only model identity, stream intent, and configured VM options are gateway-owned. Upstream physical model names are replaced with the virtual model in response objects and events. |
previous_response_id, conversation, background, and store retain their native Responses semantics. This is not byte-transparent because JSON may be reserialized. |
VM Temperature, TopP, and NumPredict override temperature, top_p, and max_output_tokens. Other nested Responses fields remain untouched. |
Anthropic Messages client routes /v1/messages → 3 backend protocols · no physical Anthropic adapter |
/v1/messages Anthropic → Ollama Translated |
AnthropicChatRequestDecoder → canonical IL → OllamaChatProviderRequestAdapter. Ollama JSON/NDJSON becomes Anthropic message JSON or message_start/content_block_*/message_delta/message_stop SSE. |
System text, message text, base64 images, tool definitions, tool_use/tool_result, tool choice modes, temperature, top-p, max tokens, visible reasoning text, stream, finish reason, and usage. |
Anthropic image sources → Ollama images[]; max_tokens → num_predict; tool_use → function call; tool_result → tool message; reasoning text → Ollama thinking; Ollama output is rebuilt as Anthropic content blocks. |
Remote image URLs are not a portable Ollama-native contract; base64 is the verified path. Thinking signatures are discarded. Unknown content blocks remain a hard rejection; unknown top-level controls are omitted when this translated fallback is used. |
All Ollama VM controls apply. TopK, NumCtx, RepeatPenalty, and Thinking can be injected from DB even though Anthropic request fields do not directly express them. |
/v1/messages Anthropic → OpenAI Chat Translated |
AnthropicChatRequestDecoder → canonical IL → OpenAiChatProviderRequestAdapter. Chat JSON/SSE is decoded and reconstructed as Anthropic Messages output. |
System/messages, text, base64 and URL images, function tools/calls/results, tool choice, temperature, top-p, max tokens, reasoning text, stream, finish reason, and usage. |
Anthropic system content → system message; image blocks → OpenAI image_url; input_schema → function parameters; tool_use/tool_result → Chat tool calls/messages; max_tokens remains the Chat token limit. |
Thinking signatures are discarded. Unknown content blocks remain a hard rejection. Anthropic-only top-level controls prefer a future Anthropic backend but are omitted when Chat is the only eligible route. |
VM Temperature, TopP, NumPredict, and Thinking override Chat target fields. Ollama-only DB sampling/context controls do not apply to Chat. |
/v1/messages Anthropic → Responses Translated |
AnthropicChatRequestDecoder → canonical IL → OpenAiResponsesProviderRequestAdapter. Responses Items/events are decoded and rebuilt as Anthropic content blocks and SSE. |
System instructions, text, base64/URL images, function tools/calls/results, tool choice, temperature, top-p, max tokens, response reasoning text, stream, finish state, and usage. |
System → instructions; messages/images → Responses input Items; Anthropic tools → Responses function tools; named tool choice → Responses name; max_tokens → max_output_tokens; Responses reasoning/text/function output → Anthropic blocks. |
Anthropic input thinking blocks and signatures are not encoded into Responses input. Unknown content blocks cannot use this route; unknown top-level controls are omitted on fallback. Native Responses-only output Items, annotations, and citations cannot be represented in Anthropic output. |
VM Temperature, TopP, and NumPredict override Responses fields. VM Thinking, TopK, NumCtx, and RepeatPenalty have no Responses target field. |