Skip to content
Docs

Guides

SDKs

There is no Libremodel SDK to install. Point the OpenAI or Anthropic SDK you already use at Libremodel, with your key.

OpenAI SDK

Set the base URL to https://api.libremodel.ai/v1. Chat Completions, Responses and the model list work as they do with OpenAI.

curl https://api.libremodel.ai/v1/chat/completions \
  -H "Authorization: Bearer $LIBREMODEL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4.1-flash-1017",
    "messages": [{"role": "user", "content": "Hello, Libremodel"}]
  }'

The Responses API works the same way, with client.responses.create:

curl https://api.libremodel.ai/v1/responses \
  -H "Authorization: Bearer $LIBREMODEL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4.1-flash-1017",
    "input": "Hello, Libremodel",
    "reasoning": {"effort": "high"}
  }'

Anthropic SDK

Set the base URL to https://api.libremodel.ai, without /v1: the SDK adds /v1/messages itself. It sends the key in x-api-key, and that works too.

curl https://api.libremodel.ai/v1/messages \
  -H "x-api-key: $LIBREMODEL_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4.1-flash-1017",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello, Libremodel"}]
  }'

With thinking on, the first content block is thinking. Read the text blocks for the answer.

Other libraries

Any library or tool that talks to the OpenAI API and lets you change its base URL works the same way: base URL https://api.libremodel.ai/v1, your key, and a model ID from Models. For coding agents such as Claude Code, Codex or OpenCode there is a step-by-step guide in Integrations.

Errors and retries

The SDKs raise our errors as their own exceptions, with the status code and the body. Retry 429 and 503 after a short wait, and don't retry the rest. Every code: Limits and errors.