# OpenAI-Compatible Endpoint

How `POST /v1/chat/completions` lets any OpenAI client use Agenvoy as its model router.

`/v1/chat/completions` is stateless: include prior messages in every request when continuity is needed. `reasoning_effort` accepts `none` `low` `medium` `high` `xhigh` `max` (plus the aliases `minimal` `extra` `ultra`); an omitted or unrecognized value falls back to the level the model selector picks for the request (`medium` when it picks none). `model` defaults to `auto`.

By default a completion runs with none of Agenvoy's own tools: only the `tools` the client sends are offered. With the header `X-Agenvoy-Agent: 1` (or `true` / `yes`) it runs as an Agenvoy agent instead — Agenvoy's system prompt plus every tool except the TUI-only ones. Tool confirmations are skipped on this endpoint either way.

Any OpenAI client can use Agenvoy as its model router: set the SDK's base URL to `http://127.0.0.1:17989/v1`. The endpoint does not check the API key, so any placeholder value works. `GET /v1/models` lists every registered model plus `auto` (see Model Endpoints).

| `model` | Which model answers | Fallback |
|---|---|---|
| `auto` (default) | The dispatcher model picks a worker model for the request's work kind (see Model Routing) | When a send fails, the next model in the priority order that is on a different provider and passes a 10-second health check takes over, for up to four rounds |
| `<provider>@<model>` | That registered model as-is; an unregistered name fails with `[Not found] model` | None |

Timeouts and rate limits are retried on the same model up to three times before any fallback. Without `stream` the reply is one `chat.completion` object, and an error that survives fallback returns `502` with `type: upstream_error`; with `stream: true` the reply is SSE `chat.completion.chunk` frames ending in `data: [DONE]`. `usage` reports `prompt_tokens` (cache reads included), `completion_tokens` and `prompt_tokens_details.cached_tokens`. When the client sends `tools` and the model calls one, the reply carries `tool_calls` with `finish_reason: "tool_calls"` and the client runs the tool itself. When the system prompt comes from Zed, the project root listed in it becomes the work directory; otherwise the home directory is used.

LiteLLM is a proxy server that puts many providers behind one OpenAI-format API, and OpenRouter is a hosted API that routes requests across providers. Agenvoy's endpoint runs on your own machine and routes across the models you registered in Agenvoy, including the Claude Code and Codex subscription providers, choosing one by work kind.
