API reference

API reference

Use one LivRouter key with the request format your application expects. Choose the protocol first, then select a model that supports it. A model being listed does not guarantee support for every endpoint.

Base URL and authentication

bash
export OPENAI_API_KEY="your-livrouter-api-key"export LIVROUTER_MODEL="your-model-id"export OPENAI_BASE_URL="https://api.livrouter.com/v1"

OpenAI-compatible requests use Authorization: Bearer $OPENAI_API_KEY. Anthropic Messages requests use x-api-key with your LivRouter key and anthropic-version. Send Content-Type: application/json unless an endpoint explicitly requires multipart data.

Append the version once. OpenAI SDK clients use https://api.livrouter.com/v1. Anthropic SDK clients use https://api.livrouter.com because the SDK adds /v1/messages. Raw HTTP requests always include the full endpoint path.

Endpoint directory

MethodPathGuide
GET/v1/modelsModels available to your key
POST/v1/chat/completionsChat Completions
POST/v1/messagesAnthropic Messages
POST/v1/responsesResponses
POST/v1/images/generationsImage generations — confirm availability
POST/v1/images/editsImage edits — confirm availability

Vision, PDF, speech, embeddings, moderation, and tools retain their dedicated guides under Core API and More reference. Their availability depends on the selected model and deployment.

Common request fields

FieldRequirementBehavior
modelRequiredUse the exact model ID available to your key.
messages / inputRequiredChat and Messages use messages; Responses uses input.
streamOptional booleanEnable server-sent events. Parse events using the selected protocol.
max_tokens / max_output_tokensProtocol and model dependentMessages requires max_tokens. Responses uses max_output_tokens. Chat token limits vary by model.
temperatureModel dependentOnly send generation controls supported by the selected model.

Validate a request

  1. Follow Quickstart to verify the key and select a model.
  2. Send a short prompt before adding tools, files, or long conversations.
  3. Confirm the expected response structure and inspect usage logs.

If a request fails, read the response body as well as the HTTP status. Use the troubleshooting guide before adding retries.