Chat Completions
Unified endpoint for 130+ LLM models. OpenAI-compatible drop-in replacement — just change the base URL.
/v1/ai/chat/completionsOverview
A single endpoint that gives you access to 130+ LLM models from OpenAI, Anthropic, Google, Meta, DeepSeek, xAI, Qwen, Mistral, Perplexity, and more. Fully OpenAI-compatible — swap the base URL and it works with any OpenAI SDK.
There are two ways to call the AI API:
| Endpoint | Format | Model Source |
|---|---|---|
POST /v1/ai/chat/completions | OpenAI-compatible (snake_case) | model field in body |
POST /v1/ai/chat | YepAPI simplified (camelCase) | model field in body |
Both hit the same infrastructure. Pick whichever fits your stack.
OpenAI SDK Drop-In
Point any OpenAI SDK at YepAPI by changing the base URL:
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "https://api.yepapi.com/v1/ai",
});
const response = await client.chat.completions.create({
model: "anthropic/claude-sonnet-4.6",
messages: [{ role: "user", content: "Explain quantum computing in one paragraph." }],
});
console.log(response.choices[0].message.content);Works with Python, Node, Go, or any language with an OpenAI-compatible client.
To label requests with your app, pass the optional X-App-Name, X-App-Website and X-App-Description headers (see Authentication). Code that already sends OpenRouter's X-Title and HTTP-Referer keeps working as is.
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "https://api.yepapi.com/v1/ai",
defaultHeaders: {
"X-App-Name": "Support Bot",
"X-App-Website": "https://support.example.com",
},
});Usage
OpenAI-Compatible Endpoint
const res = await fetch("https://api.yepapi.com/v1/ai/chat/completions", {
method: "POST",
headers: {
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "anthropic/claude-sonnet-4.6",
messages: [{ role: "user", content: "What is the capital of France?" }],
temperature: 0.7,
max_tokens: 1024,
}),
});
const data = await res.json();
console.log(data.choices[0].message.content);curl -X POST https://api.yepapi.com/v1/ai/chat/completions \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-4.6",
"messages": [{"role": "user", "content": "What is the capital of France?"}],
"temperature": 0.7,
"max_tokens": 1024
}'YepAPI Simplified Endpoint
const res = await fetch("https://api.yepapi.com/v1/ai/chat", {
method: "POST",
headers: {
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "claude-sonnet-4.6",
messages: [{ role: "user", content: "What is the capital of France?" }],
temperature: 0.7,
maxTokens: 1024,
}),
});
const { data } = await res.json();
console.log(data.message.content);The /v1/ai/chat endpoint accepts short aliases like gpt-4o, claude-sonnet, or gemini-flash — no need for the full provider/model format.
Request Body
/v1/ai/chat/completions (OpenAI-compatible, snake_case)
| Parameter | Type | Required | Description | Default |
|---|---|---|---|---|
model | string | Yes | Model ID (e.g. openai/gpt-4o, anthropic/claude-sonnet-4.6) | — |
messages | object[] | Yes | Array of { role, content } objects | — |
max_tokens | number | No | Maximum tokens in the response | Model default |
temperature | number | No | Sampling temperature (0.0–2.0) | 1.0 |
top_p | number | No | Nucleus sampling threshold | 1.0 |
frequency_penalty | number | No | Penalize repeated tokens | 0 |
presence_penalty | number | No | Penalize tokens already present | 0 |
stop | string | string[] | No | Stop sequences | — |
stream | boolean | No | Enable SSE streaming | false |
response_format | object | No | { "type": "json_object" } or { "type": "json_schema", "json_schema": {...} } for structured output. Forwarded to the model; support varies by provider. | — |
tools | object[] | No | Function-calling tool definitions in the OpenAI shape ({ type: "function", function: { name, description, parameters } }) | — |
tool_choice | string | object | No | "auto", "none", "required", or a specific function | "auto" when tools are set |
parallel_tool_calls | boolean | No | Allow the model to emit several tool calls in one turn | Model default |
web_search | boolean | object | No | Ground the answer in a live web search. true, or { "max_results": 5, "search_prompt": "…" }. See Web search and sources. | false |
web_search_options | object | No | Provider-native search controls (e.g. { "search_context_size": "high" }), forwarded as-is. | — |
Messages accept the full OpenAI shape, so a tool-calling loop round-trips: an assistant turn may carry tool_calls, and a tool role message carries tool_call_id with the result as content.
/v1/ai/chat (YepAPI simplified, camelCase)
| Parameter | Type | Required | Description | Default |
|---|---|---|---|---|
model | string | No | Model ID or alias (e.g. gpt-4o, claude-sonnet) | openai/gpt-4o-mini |
messages | object[] | Yes | Array of { role, content } objects | — |
maxTokens | number | No | Maximum tokens in the response | Model default |
temperature | number | No | Sampling temperature (0.0–2.0) | 1.0 |
topP | number | No | Nucleus sampling threshold | 1.0 |
frequencyPenalty | number | No | Penalize repeated tokens | 0 |
presencePenalty | number | No | Penalize tokens already present | 0 |
stop | string | string[] | No | Stop sequences | — |
stream | boolean | No | Enable SSE streaming | false |
responseFormat | object | No | Structured output, same shape as response_format above | — |
tools | object[] | No | Function-calling tool definitions, same shape as above | — |
toolChoice | string | object | No | Same as tool_choice above | — |
parallelToolCalls | boolean | No | Same as parallel_tool_calls above | — |
webSearch | boolean | object | No | Same as web_search above. See Web search and sources. | false |
webSearchOptions | object | No | Same as web_search_options above | — |
Web search and sources
Any chat model can answer from a live web search. Set web_search (or
webSearch on /v1/ai/chat) and the model receives current search results
along with your prompt:
curl -X POST https://api.yepapi.com/v1/ai/chat \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o-mini",
"messages": [{ "role": "user", "content": "What is the current stable version of Rust?" }],
"webSearch": { "max_results": 5 }
}'| Option | Description | Default |
|---|---|---|
max_results | How many search results the model is given (1–20). | 5 |
search_prompt | Replaces the instruction that introduces the results to the model. | — |
It works the same across providers — OpenAI, Anthropic, Google, xAI and the rest — so you can run one prompt through several models and compare. The Perplexity Sonar models search on every request without the option.
Where the sources are
/v1/ai/chat returns data.sources: one list of the pages the answer drew
on, whichever model produced it.
{
"ok": true,
"data": {
"model": "openai/gpt-4o-mini",
"message": {
"role": "assistant",
"content": "The current stable version of Rust is 1.99.0 …",
"annotations": [
{ "type": "url_citation", "url_citation": { "url": "https://github.com/rust-lang/rust/releases", "title": "Releases · rust-lang/rust · GitHub" } }
]
},
"sources": [
{ "url": "https://github.com/rust-lang/rust/releases", "title": "Releases · rust-lang/rust · GitHub" },
{ "url": "https://doc.rust-lang.org/stable/releases.html", "title": "Rust Release Notes" }
],
"usage": { "promptTokens": 1820, "completionTokens": 42, "totalTokens": 1862 },
"costUsd": 0.02
}
}data.sources[]—{ url, title }, de-duplicated, in the order cited. Absent when the answer used no web sources.data.message.annotations[]— the provider's own citation entries, for callers who want the raw form.
/v1/ai/chat/completions stays a 1:1 OpenAI-compatible response, so there the
sources are in choices[0].message.annotations only.
When streaming, citation annotations arrive in the message deltas; the merged
sources list is part of the non-streaming response.
Cost
A search adds the price of the search itself and of the extra input tokens the
results take up — typically about a cent on a small model, more on models with
expensive input tokens. The total is in costUsd as usual.
Model Aliases
The /v1/ai/chat endpoint accepts short aliases so you don't need the full provider/model format:
| Alias | Resolves To |
|---|---|
gpt-4o | openai/gpt-4o |
gpt-4o-mini | openai/gpt-4o-mini |
gpt-5.4 | openai/gpt-5.4 |
claude-opus | anthropic/claude-opus-5.5 |
claude-sonnet | anthropic/claude-sonnet-5.5 |
claude-haiku | anthropic/claude-haiku-5.5 |
gemini-pro | google/gemini-2.5-pro |
gemini-flash | google/gemini-3.8-flash |
grok | x-ai/grok-4.7 |
deepseek-v3 | deepseek/deepseek-v3.2 |
deepseek-r1 | deepseek/deepseek-r1-0528 |
sonar-pro | perplexity/sonar-pro |
llama-scout | meta-llama/llama-4-scout |
qwen | qwen/qwen3.8-max-0902 |
mistral-small | mistralai/mistral-small-2603 |
gpt-6.1 | openai/gpt-6.1-sol |
gemini-4 | google/gemini-4-argon |
kimi-k3 | moonshotai/kimi-k3 |
mistral-large | mistralai/mistral-large-4-0 |
mercury | inception/mercury-3 |
You can also pass the full provider/model format to either endpoint.
Response Formats
/v1/ai/chat/completions (OpenAI-compatible)
{
"id": "chatcmpl-abc123",
"object": "text_completion",
"created": 1713100000,
"model": "anthropic/claude-sonnet-4.6",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The capital of France is Paris."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 14,
"completion_tokens": 8,
"total_tokens": 22
}
}/v1/ai/chat (YepAPI simplified)
{
"ok": true,
"data": {
"id": "chatcmpl-abc123",
"model": "anthropic/claude-sonnet-4.6",
"message": {
"role": "assistant",
"content": "The capital of France is Paris."
},
"usage": {
"promptTokens": 14,
"completionTokens": 8,
"totalTokens": 22
},
"costUsd": 0.000162
}
}Streaming
Set "stream": true to receive Server-Sent Events.
/v1/ai/chat/completions (OpenAI-compatible SSE)
data: {"id":"chatcmpl-abc123","model":"anthropic/claude-sonnet-4.6","choices":[{"index":0,"delta":{"role":"assistant","content":"The"},"finish_reason":null}]}
data: {"id":"chatcmpl-abc123","model":"anthropic/claude-sonnet-4.6","choices":[{"index":0,"delta":{"content":" capital"},"finish_reason":null}]}
data: [DONE]/v1/ai/chat (YepAPI simplified SSE)
data: {"id":"chatcmpl-abc123","delta":{"role":"assistant","content":"The"},"model":"anthropic/claude-sonnet-4.6","index":0}
data: {"id":"chatcmpl-abc123","delta":{"content":" capital"},"model":"anthropic/claude-sonnet-4.6","index":0}
data: [DONE]List Available Models
curl https://api.yepapi.com/v1/ai/modelsReturns every available model with pricing, context window, and capabilities. This endpoint is free and does not require authentication.
We handle auth, billing, and response normalization — you just send messages.