Skip to content
Browse the docs

Guides · Python · JavaScript · 4 min

Switch from the OpenAI SDK

Change the base URL and the key, then check the short list of things that differ.

If your application already uses an OpenAI SDK or any client with a configurable base URL, moving it to Unbound is a configuration change.

What changes

SettingValue
Base URLhttps://api.useunbound.ai/v1
API keyAn Unbound key from Settings → API → Keys
ModelAn id from GET /v1/models

Nothing else in your code needs to move for chat completions and image generation.

Python

python
from openai import OpenAI

client = OpenAI(
    base_url="https://api.useunbound.ai/v1",
    api_key="<your Unbound key>",
)

JavaScript and TypeScript

javascript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.useunbound.ai/v1",
  apiKey: process.env.UNBOUND_API_KEY,
});

Environment variables

The OpenAI SDKs read two environment variables, so many applications need no code change at all:

bash
export OPENAI_BASE_URL="https://api.useunbound.ai/v1"
export OPENAI_API_KEY="<your Unbound key>"

Clients with a custom provider setting

Any tool that lets you add an OpenAI-compatible provider can use Unbound. A provider entry in the style used by OpenCode-like coding clients looks like this:

json
{
  "provider": {
    "unbound": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Unbound AI",
      "options": { "baseURL": "https://api.useunbound.ai/v1" },
      "models": { "<model-id>": { "name": "<display name>" } }
    }
  }
}

Unbound implements the chat format these clients use. Compatibility with a specific third-party client is confirmed release by release and noted in the changelog; until a client is listed there, treat it as untested.

Things to check after switching

  • Model ids. Replace hard-coded ids with ids from GET /v1/models.
  • Endpoints you use. Chat completions, image generation and the model list are live. Embeddings, audio, video and image editing are not yet; see the reference.
  • Unsupported chat parameters. n, logprobs and logit_bias are not forwarded.
  • Image responses. The default is b64_json, the same as recent OpenAI image models. Ask for "response_format": "url" if your code expects links.
  • Error handling. Status codes and the error envelope match OpenAI, so existing retry logic keeps working. See Handle errors and rate limits.