Docs

This guide covers llm-api-adapter==0.11.0. Start with the Quickstart to send a first message.

Installation

Use Python 3.10–3.14. Install Core in a virtual environment.

python -m pip install llm-api-adapter==0.11.0
  • Sync calls use requests by default.
  • For async calls, run python -m pip install "llm-api-adapter[async]==0.11.0".
  • For sync HTTPX, run python -m pip install "llm-api-adapter[httpx]==0.11.0" and pass transport="httpx".

See how provider packages extend Core.

Provider setup

Pass the provider ID as organization, the exact model ID as model, and a key from that provider as api_key. The examples read the key from the environment and pass it to the constructor.

For an optional provider such as Mistral, add its package alongside Core.

python -m pip install llm-api-adapter==0.11.0 llm-api-adapter-mistral==0.1.7
Provider and IDPackage in the catalogKey in examples
Anthropic anthropicllm-api-adapter==0.11.0ANTHROPIC_API_KEY
Google googlellm-api-adapter==0.11.0GOOGLE_API_KEY
OpenAI openaillm-api-adapter==0.11.0OPENAI_API_KEY
DeepSeek deepseekllm-api-adapter-deepseek==0.1.2DEEPSEEK_API_KEY
Kimi kimillm-api-adapter-kimi==0.1.3KIMI_API_KEY
Mistral mistralllm-api-adapter-mistral==0.1.7MISTRAL_API_KEY
Qwen qwenllm-api-adapter-qwen==0.1.3QWEN_API_KEY
xAI xaillm-api-adapter-xai==0.1.5XAI_API_KEY
Z.ai zaillm-api-adapter-zai==0.1.3ZAI_API_KEY

For Qwen, also pass the Frankfurt Global workspace_id to each chat or streaming call. Generate an installation command and Python snippet for a model in the interactive example.

Python API

Import UniversalLLMAPIAdapter from llm_api_adapter.universal_adapter. Use typed messages such as UserMessage from llm_api_adapter.models.messages.chat_message.

  • chat() returns a ChatResponse. For async, use await adapter.achat(...).
  • stream_chat() yields text chunks for a for loop. astream_chat() is used with async for.
  • Pass tools to get tool calls back for your application to execute. Use json_schema or response_model for supported structured output.
  • Use max_tokens for the output budget and timeout_s for the per-request timeout.

Try the sync example or seeasync and streaming examples andtool and schema examples.

Compatible endpoints

Both modes are installed with Core. Pass the server's exact model, a nonempty api_key, and an absolute HTTP(S) base_url including the version and any proxy prefix, such as http://localhost:8000/v1. The adapter appends the resource path.

  • organization="openai_compatible" uses /chat/completions by default. Set api_variant="responses" to use /responses.
  • organization="anthropic_compatible" uses /messages. Leave api_variant unset and pass a positive integer max_tokens on every request.

Choose the protocol and send the full conversation history on each request. The adapter uses the selected protocol for every call. Check the server's documentation for supported features. Compatible connections use caller-supplied settings and tariffs, even when the model ID matches a native entry.

See connection examples for Chat Completions and Responses,Messages, andasync connections.

Limits

  • Check the model catalog for context windows, output limits, and model-specific support for tools, files, reasoning, and structured output.
  • Registered rules can omit unsupported sampling parameters. Supplying a value other than the default can produce a warning. See request compatibility.
  • Usage depends on the counts reported by the provider. Calculated costs are estimates based on a known tariff and applicable usage. For a compatible connection, supply a caller tariff to calculate costs.
  • Streaming completion callbacks require a successful end to the stream. Close a stream explicitly if you stop reading it early.

See usage and pricing examples and the catalog's source and date.