API Reference
One API key and one base URL for every OpenAI, Anthropic, Google, and xAI model — plus image, video, and audio generation — in the standard OpenAI-compatible format. If your app can call the OpenAI API, it can call 1K4: change two lines.
Quickstart
Base URL: https://api.1k4.ai/v1
Auth: send your project key as an OpenAI-style bearer token — Authorization: Bearer <your key>. Mint or copy a key on the install page.
curl
curl https://api.1k4.ai/v1/chat/completions \
-H "Authorization: Bearer $ONEKEY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.2",
"messages": [{"role": "user", "content": "Hello"}]
}'Python (openai)
from openai import OpenAI
client = OpenAI(
base_url="https://api.1k4.ai/v1",
api_key="YOUR_1K4_KEY",
)
resp = client.chat.completions.create(
model="gpt-5.2",
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)Node (openai)
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.1k4.ai/v1",
apiKey: process.env.ONEKEY_API_KEY,
});
const resp = await client.chat.completions.create({
model: "gpt-5.2",
messages: [{ role: "user", content: "Hello" }],
});
console.log(resp.choices[0].message.content);The same key and base URL reach every provider — swap the model: request claude-sonnet-4-5 and it routes to Anthropic, gemini-2.5-pro to Google, grok-4-0709 to xAI. No extra accounts, no code changes.
Base URL & compatibility
The native primary base URL is https://api.1k4.ai/v1. For compatibility, the legacy hosts remain fully supported and route to the same engine: https://api.1key4ai.com/v1 and the apex https://1k4.ai/v1. 1K4 works with any OpenAI SDK (Python, Node, Go) and any app with a custom-OpenAI-endpoint setting — Cursor, TypingMind, Open WebUI, LibreChat, Continue.dev, and more.
Models & routing
Request a model by its name, or by a short alias (for example claude-sonnet-4-5 or gemini-flash-latest) and 1K4 routes it to the right provider automatically. Text models come from OpenAI, Anthropic, Google, and xAI; media adds image, video, and audio generation (OpenAI, Google, fal.ai for images; Sora for video; OpenAI for speech and transcription).
For the current, authoritative list see the pricing page or call GET /v1/models with your key.
Endpoints
/v1/chat/completionsChat + streaming (OpenAI format)/v1/completionsLegacy text completion/v1/messagesAnthropic Messages format/v1/responsesResponses API (reasoning models)/v1/modelsList the models your key can call/v1/embeddingsText embeddings/v1/images/generationsImage generation + /v1/images/edits/v1/audio/speechText-to-speech, plus /v1/audio/transcriptions + /translations/v1/videosVideo generation (async)
Also available: /v1/rerank, /v1/moderations, and a realtime websocket at /v1/realtime. Not supported: /v1/files, /v1/fine-tunes, and /v1/images/variations.
Good to know
- Reasoning models omit temperature. Reasoning / Responses-pathway models — for example
gpt-5-pro,gpt-5.4-pro,o3/o4,codex, and deep-research models — reject thetemperatureparameter. Omit it for those. - Media billing. Image, video, and audio models use their own endpoints (above) and are billed per unit, not per token.
- Local models. Ollama / local models run through the 1K4 bridge on your own machine, not this cloud endpoint.
- Billing protection. A missing or invalid key returns
401with a JSONerrorobject; requests stop cleanly at a zero balance (no debt).
Next
See how 1K4 works for the architecture, or the pricing page for model costs. Questions? support@1key4ai.com.