Skip to main content

Model Backends

Akritas requires /v1/models and /v1/chat/completions. Point -base-url at the path ending in /v1. An empty -upstream-model selects the first discovered model; set it explicitly when ordering is not stable.

export OPENAI_API_KEY=example-upstream-token
./bin/akritas serve \
-base-url https://example.com/v1 \
-upstream-model example-model

Change the environment-variable name with -upstream-api-key-env. Akritas does not own the upstream tokenizer, so facade usage counters are zero. Streaming is buffered: generation and tool execution complete before a single SSE content chunk is sent.

Output-token compatibility​

Chat Completions providers and model families do not all accept the same output-token field. Akritas begins with max_tokens for compatibility with legacy and local endpoints. If the upstream returns a structured 400 or 422 error that explicitly rejects that field, Akritas retries once with max_completion_tokens and remembers the accepted field for later requests. The same negotiation works in the opposite direction after switching to a backend that accepts only max_tokens.

Only a recognized unsupported-parameter error triggers this retry. Authentication failures, rate limits, malformed responses, and unrelated upstream errors are returned without token-field negotiation. The configured -max-tokens value continues to control the requested output allowance regardless of the wire field selected for the backend.

The OpenAI Chat Completions reference defines max_completion_tokens as the current output bound and marks max_tokens as deprecated and incompatible with some reasoning models. See the official OpenAI API reference.

Response language​

Use -response-language to choose the language for model-generated prose:

./bin/akritas serve \
-base-url https://example.com/v1 \
-upstream-model example-model \
-response-language pt-BR

The value is a validated BCP 47 tag, not a fixed language enum. It applies to chat answers, investigation steps and reasons, structured Alertmanager text, and change proposals. Akritas instructs the model to preserve code, commands, paths, hostnames, metric names, labels, and evidence references exactly. The user's message language does not override the host setting.

The Web UI, fixed Markdown headings, API errors, validation messages, and logs remain English. Language adherence is model behavior rather than a host-side translation guarantee.