Endpoints
Chat completions
Send chat messages to any text model with POST /chat/completions, using the OpenAI chat format, roles, parameters and response fields.
Try it in the playgroundThe chat completions endpoint uses the OpenAI chat format and works with every text model in the catalog: GPT, Claude, Gemini, Llama, DeepSeek, Mistral and hundreds more. The request body goes to the upstream provider unchanged. api14 only checks your key, model, limits and balance, then records usage when the request finishes.
POST https://api14.com/api/v1/chat/completions
Authorization: Bearer sk-api14-...
Content-Type: application/json
Request
| Parameter | Type | Description |
|---|---|---|
model | string, required | Model id, e.g. anthropic/claude-sonnet-4.5. Variants like :online or :nitro are allowed. See Model ids. |
messages | array, required | Conversation as { role, content } objects. Roles: system, developer, user, assistant, tool. |
models | string[] | Fallback models to try in order if the first one fails. See Provider routing. |
stream | boolean | Stream tokens as server-sent events. See Streaming. |
max_tokens / max_completion_tokens | integer | Upper bound on generated tokens. |
temperature | number | Sampling temperature, usually 0–2. |
top_p, top_k, min_p, top_a | number | Other sampling controls. Models that don't support them ignore them. |
frequency_penalty, presence_penalty, repetition_penalty | number | Repetition controls. |
stop | string | string[] | Stop sequences. |
seed | integer | Best-effort deterministic sampling. |
logprobs, top_logprobs | boolean, integer | Return token log probabilities when the model supports them. |
tools, tool_choice, parallel_tool_calls | Function calling. See Tool calling. | |
response_format | object | JSON mode or JSON Schema output. See Structured outputs. |
reasoning, include_reasoning | object, boolean | Thinking controls. See Reasoning. |
plugins, web_search_options | Web search. See Web search. | |
provider | object | Upstream provider preferences. See Provider routing. |
modalities | string[] | e.g. ["image", "text"] for image output, or ["text", "audio"] for audio output. |
prediction | object | Predicted output ({ type: "content", content }) to cut latency on edits. |
transforms | string[] | e.g. ["middle-out"] to compress prompts that exceed the context window. |
user | string | Your own end-user identifier. |
Message content can be a string or an array of content parts (text, image_url, file, input_audio). See Vision & files.
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);
Response
{
"id": "gen-1760000000-abc123",
"object": "chat.completion",
"created": 1760000000,
"model": "anthropic/claude-sonnet-4.5",
"provider": "Anthropic",
"choices": [
{
"index": 0,
"finish_reason": "stop",
"message": { "role": "assistant", "content": "Hello! How can I help you today?" }
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 9,
"total_tokens": 21,
"prompt_tokens_details": { "cached_tokens": 0 },
"completion_tokens_details": { "reasoning_tokens": 0 },
"cost": 0.000171
}
}
usage.cost is the cost of the request in USD. api14 debits it from your balance after the request finishes. The id is the generation id, which you can look up later with Generation lookup.
Billing notes
- You pay the model's listed price; the charge is returned in
usage.cost. See Pricing & billing. - You are not charged for failed requests (any 4xx or 5xx status).
- If the request includes
models: [...], every fallback model must be allowed for your key and plan, or the gateway rejects the request before it is sent upstream.
Errors
| Status | Code | When |
|---|---|---|
| 400 | model_required | model is missing. |
| 400 | invalid_json | The body is not a JSON object. |
| 401 | invalid_api_key | The key is missing, invalid or revoked. |
| 402 | insufficient_balance | Your USD balance is $0. |
| 403 | model_not_allowed / plan_required | Your key's allowlist or your plan does not cover this model. |
| 404 | model_not_found | Unknown or disabled model id. |
| 413 | payload_too_large | The request body is larger than 25 MB. |
| 429 | rate_limited / daily_limit_reached | RPM limit or the key's daily USD limit was reached. |
| 502 | upstream_unavailable | The upstream provider could not be reached. |
Upstream errors such as context length exceeded or content moderation come back with their original status code and the same error shape. See Errors.