We use cookies. Cookies and browser storage keep you signed in and remember your preferences. With your permission we also measure how the site is used. You can any time. See our cookie policy.

OpenAI SDK compatibility

Getting started

OpenAI SDK compatibility

Use the official OpenAI SDKs unchanged with api14 and migrate from OpenAI or any compatible API by changing only the base URL and key.

api14 speaks the OpenAI API. Any official OpenAI SDK, and any tool that accepts a custom OpenAI base URL, works without code changes, you only change the base URL and the API key.

The two values to change

SettingValue
Base URLhttps://api14.com/api/v1
API keyyour sk-api14-... key
import OpenAI from 'openai'

const client = new OpenAI({
  baseURL: 'https://api14.com/api/v1',
  apiKey: process.env.API14_API_KEY,
})
import os
from openai import OpenAI

client = OpenAI(base_url="https://api14.com/api/v1", api_key=os.environ["API14_API_KEY"])

Many SDKs also read the OPENAI_BASE_URL and OPENAI_API_KEY environment variables, so you can switch without touching code at all.

What is compatible

OpenAI featureapi14
chat.completions.create incl. stream, tools, response_formatSupported for every text model
responses.createSupported
completions.createSupported
embeddings.createSupported
images.generateSupported (/images/generations)
audio.speech.createSupported
audio.transcriptions.createSupported (multipart)
models.list / models.retrieveSupported, with prices and categories
Error shape { error: { message, type, code } }Same, SDKs raise their normal APIError

Endpoints that only exist at OpenAI (Assistants, Threads, fine-tuning, files, batches, vector stores and moderations) are not available.

Migrating from OpenAI

  1. Set the base URL to https://api14.com/api/v1 and use your api14 key.
  2. Prefix model names with the provider: gpt-5-mini becomes openai/gpt-5-mini, text-embedding-3-small becomes openai/text-embedding-3-small.
  3. That's it. You can now also switch to any other provider by changing the model id, for example anthropic/claude-sonnet-4.5 or google/gemini-2.5-pro.
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api14.com/api/v1",
  apiKey: process.env.API14_API_KEY,
});

const result = await client.chat.completions.create({
  "model": "openai/gpt-5-mini",
  "messages": [
    {
      "role": "user",
      "content": "Explain vector databases in two sentences."
    }
  ]
});
console.log(result.choices[0].message.content);

Migrating from another OpenAI-compatible API

Change the base URL and the key:

  1. Set the base URL to https://api14.com/api/v1.
  2. Use your api14 key as the API key.
  3. Use model ids in provider/model format (for example openai/gpt-5-mini). Variants (:free, :online, :nitro, :floor), provider routing, models fallbacks, reasoning, plugins, transforms and usage are supported.

Differences to know about:

  • Billing is a USD balance. GET /credits returns total_credits and total_usage in USD, plus a balance_usd field. See Balance & key info.
  • Usage cost is always included. The gateway always asks the upstream for usage.cost, so every response reports its price.
  • Headers such as HTTP-Referer and X-Title are set by the gateway; you do not need to send them.
  • Video job URLs point back at api14 (/api/v1/videos/{id}), never at the upstream. See Video.

Extra gateway parameters in the SDKs

Fields that the OpenAI SDK does not know about can still be sent:

await client.chat.completions.create({
  model: 'openai/gpt-5-mini',
  messages: [{ role: 'user', content: 'Hi' }],
  // @ts-expect-error api14 extension
  provider: { sort: 'price' },
})
client.chat.completions.create(
    model="openai/gpt-5-mini",
    messages=[{"role": "user", "content": "Hi"}],
    extra_body={"provider": {"sort": "price"}},
)

See Provider routing & fallbacks, Reasoning and Web search.