# The server's AI providers

The server runs no model: its LLM (`AITODO_SERVER_LLM_PROVIDER`) and its embedding (`AITODO_SERVER_EMBED_URL`) call remote APIs.

Each has a place: `server` (it leaves the company) or `infrastructure` (the company's own). A bad setting stops the server at startup.

## Details

- **One switch:** the project's `llmEnabled` (`tkt project llm enable`) covers both parts of the server AI, the LLM and the embedding; it can be switched on when either is set up on the server.
- **LLM:** `AITODO_SERVER_LLM_PROVIDER` = `anthropic` (default, `ANTHROPIC_API_KEY`, `server`), `bedrock`, `vertex`, `foundry` (Claude in the company's cloud, `infrastructure`) or `openai` (an OpenAI-compatible endpoint: vLLM, Ollama, Azure OpenAI).
- **Embedding:** `AITODO_SERVER_EMBED_URL` (an OpenAI-compatible `/embeddings` base URL) and `AITODO_SERVER_EMBED_MODEL`; then `tkt search` on a server-hosted store is hybrid, and its `--json` `embedding` names the provider and the place. Measured choice: Azure OpenAI `text-embedding-3-large` (URL `https://<resource>.openai.azure.com/openai/v1`, the model is the deployment's name); `-3-small` is weak in Hungarian.
- **Claude in the company's cloud:** `bedrock`: `AITODO_SERVER_LLM_REGION`, the IAM role or `AWS_BEARER_TOKEN_BEDROCK`, the model with the `anthropic.` prefix (default `anthropic.claude-opus-5-5`); `vertex`: `AITODO_SERVER_LLM_REGION`, `AITODO_SERVER_LLM_GCP_PROJECT`, the workload identity; `foundry`: `AITODO_SERVER_LLM_FOUNDRY_RESOURCE`, `ANTHROPIC_FOUNDRY_API_KEY`. Structured outputs and effort work on all three; the fallback model after a refusal is the Anthropic API's only. The server image carries the `aitodo[server-cloud]` extra.
- **OpenAI-compatible LLM:** `AITODO_SERVER_LLM_URL`, `AITODO_SERVER_LLM_MODEL` (required), `AITODO_SERVER_LLM_KEY` (if it needs one); the server checks the answer against the schema, asks once more, then `ERR_LLM_UPSTREAM`. Its place is `server` by default (it leaves the company); `AITODO_SERVER_LLM_PLACE=infrastructure` when the endpoint is the company's own.
- **Embedding:** `AITODO_SERVER_EMBED_KEY` (if it needs one), `AITODO_SERVER_EMBED_PLACE` = `server` (default) or `infrastructure`. The vector cache lives next to the store, keyed by project, `server:<model>` and text: a new model re-embeds, never mixes.
- **TLS:** https; plain http only to this machine, or with `AITODO_SERVER_ALLOW_HTTP=1`. Keys only from the environment or the platform's identity; never in a reply, a log or a run's environment.
- **Embed API** for a repo store's client (read + `llm`, the project's AI on): `GET /v1/projects/{p}/embed` gives `{id, model, place}`; `POST /v1/projects/{p}/embed` `{texts}` (at most 64 texts, the body within `AITODO_SERVER_LLM_MAX_BYTES`, else 413 `ERR_PAYLOAD_TOO_LARGE` before any call) gives `{id, place, vectors}`. The server keeps and logs no text and no vector; the call counts toward the project's caps and limits (429 `ERR_LLM_QUOTA`, `ERR_RATE_LIMITED`). Not set or AI off: 503 `ERR_LLM_NOT_CONFIGURED`; the endpoint's failure: 502 `ERR_LLM_UPSTREAM`.
- `tkt project llm usage --json` names `provider` and `place`; the answer cache's key holds the provider.

## Related

- Env var: [`AITODO_SERVER_LLM_PROVIDER`](/en/docs/reference/env.md#AITODO_SERVER_LLM_PROVIDER): Where the server LLM runs: anthropic, bedrock, vertex, foundry or openai (an OpenAI-compatible endpoint)
- Env var: [`AITODO_SERVER_LLM_REGION`](/en/docs/reference/env.md#AITODO_SERVER_LLM_REGION): The cloud region of the bedrock or vertex server LLM
- Env var: [`AITODO_SERVER_LLM_GCP_PROJECT`](/en/docs/reference/env.md#AITODO_SERVER_LLM_GCP_PROJECT): The Google Cloud project of the vertex server LLM
- Env var: [`AITODO_SERVER_LLM_FOUNDRY_RESOURCE`](/en/docs/reference/env.md#AITODO_SERVER_LLM_FOUNDRY_RESOURCE): The Microsoft Foundry resource of the foundry server LLM
- Env var: [`ANTHROPIC_FOUNDRY_API_KEY`](/en/docs/reference/env.md#ANTHROPIC_FOUNDRY_API_KEY): The key of the foundry server LLM; a secret
- Env var: [`AWS_BEARER_TOKEN_BEDROCK`](/en/docs/reference/env.md#AWS_BEARER_TOKEN_BEDROCK): A Bedrock API key for the bedrock server LLM; without it the IAM role is used
- Env var: [`AITODO_SERVER_LLM_URL`](/en/docs/reference/env.md#AITODO_SERVER_LLM_URL): The base URL of the openai server LLM, e.g.
- Env var: [`AITODO_SERVER_LLM_KEY`](/en/docs/reference/env.md#AITODO_SERVER_LLM_KEY): The key of the openai server LLM, if it needs one; a secret
- Env var: [`AITODO_SERVER_LLM_PLACE`](/en/docs/reference/env.md#AITODO_SERVER_LLM_PLACE): Where the openai server LLM is: server (outside the company) or infrastructure (its own)
- Env var: [`AITODO_SERVER_EMBED_URL`](/en/docs/reference/env.md#AITODO_SERVER_EMBED_URL): The base URL of the server's OpenAI-compatible embedding endpoint; unset, the server embeds nothing
- Env var: [`AITODO_SERVER_EMBED_MODEL`](/en/docs/reference/env.md#AITODO_SERVER_EMBED_MODEL): The embedding model the server asks for; needed with AITODO\_SERVER\_EMBED\_URL
- Env var: [`AITODO_SERVER_EMBED_KEY`](/en/docs/reference/env.md#AITODO_SERVER_EMBED_KEY): The key of the server's embedding endpoint, if it needs one; a secret
