Skip to main content

Providers

Freyja reaches a provider in one of two ways. Both use the same code paths, and neither is more supported than the other.

Use whenHow
Built-inOpenAI, Gemini, AnthropicEndpointPreset::OpenAi
CustomEverything elseClient::custom(dialect, name, url, key)

Built-in providers​

Three presets, for the three first-party vendors whose endpoints Freyja is willing to promise stay current. That is not the same as the number of wire formats: Freyja implements four dialects, and OpenAiChat is implemented and tested but has no preset, because every endpoint speaking it is third party. See the four wire dialects.

ProviderKey variableDefault modelNotes
OpenAIOPENAI_API_KEYgpt-5.6-solResponses API, the most complete mapping
GeminiGEMINI_API_KEYgemini-3.5-flashDeclines metadata and three reasoning_effort levels, at the endpoint rather than locally
AnthropicANTHROPIC_API_KEYclaude-opus-5Requires max_tokens, defaulted for you
let client = Client::from_env(EndpointPreset::Anthropic)?;
let agent = Agent::new(client);

All three complete a live tool round trip. Read the provider page before relying on a capability; coverage is not uniform, and each page has a table saying exactly what is refused.

Everything else​

Most hosted inference APIs copy a format Freyja already speaks, so they need no code at all:

let client = Client::custom(
Dialect::OpenAiChat,
"DeepSeek",
"https://api.deepseek.com/v1",
api_key,
);
let agent = Agent::new(client);

That covers DeepSeek, Groq, Together, Fireworks, OpenRouter, Ollama, vLLM, LM Studio, xAI, Mistral, and Gemini's own OpenAI-compatible endpoint, among others. Custom providers has base URLs to start from and the full builder.

Why these are not built in. A preset is a standing promise that a URL and a default model are still current, and third-party endpoints change both faster than this library could verify. A stale preset fails at the vendor with a confusing 404; a missing one fails locally with a clear message, or does not fail at all because you supplied the current URL. Keeping the list short is what keeps it trustworthy.

The four wire dialects​

You pick a dialect only when using a custom endpoint. With a built-in provider it is implied.

DialectShapeWho speaks it
OpenAiChatNested, dedicated tool roleMost third-party vendors
OpenAiResponsesFlat item listOpenAI only
AnthropicNested content blocksAnthropic and Claude gateways
GeminiFlat step list, no rolesGoogle only

If a vendor's docs show messages with choices in the response, it is OpenAiChat. That is the safe first guess for anything unfamiliar.

Streaming​

All four dialects stream, through the same .stream call and the same StreamEvent sequence. Three differences reach the caller:

DialectWhat differs
GeminiNeeds ?alt=sse on the URL as well as stream: true in the body; Client::stream appends it
OpenAiChatSends stream_options: {"include_usage": true}, without which the stream reports no tokens
OpenAiChatHas no end-of-call frame, so StreamEvent::ToolCall arrives only when the body closes

All four have been run against a live endpoint for a text turn. Streamed tool calls have not, and remain covered by recorded fixtures taken from vendor documentation. Full detail in Streaming.

Choosing between them​

Portability has a price, and it is worth knowing which fields cost you.

If you useYou lose
previous_response_idAnthropic, and every OpenAiChat endpoint
response_format as free JSONAnthropic

Set none of them and your request runs anywhere. Each is refused before the network, so you find out at once rather than getting an answer that ignored you.

Debugging a provider​

When a request fails and the vendor's message is not enough, the wire reference documents the native JSON Freyja sends and receives, so you do not have to read vendor documentation to interpret an error body.

OpenAI · Chat Completions · Gemini · Anthropic