New: GLM-4.6 & Kimi K2 are now in the catalog. View models
CosmosIn

Documentation

One OpenAI & Anthropic compatible endpoint — from your first request to error recovery, everything lives on this page.

Get started in three steps

01

Create an API key

Sign up, then create a key from the dashboard. Keys start with sk-cos. Keep it safe because it is shown only once.

02

Point the base URL

Swap the base URL in your SDK or tool. Authentication uses the Authorization: Bearer <key> header.

03

Send your first request

Pick a model from the catalog and send a request as usual. Cost is recorded in the logs immediately.

~/first_request
from openai import OpenAI
client = OpenAI(
base_url="https://api.cosmosin.io/v1",
api_key="sk-cos...",
)
resp = client.chat.completions.create(
model="deepseek-v4-flash",
messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)

Authentication & API keys

Every request must carry your key in the Authorization: Bearer header. One account can hold many keys — mint separate ones per tool or project.

~/header
Authorization: Bearer sk-cos...

Key format

Keys are prefixed sk-cos followed by 48 hex characters. The full secret is shown only once at creation; afterwards the dashboard only shows a masked form (sk-cos…c56789).

Manage keys

Mint and revoke keys from the dashboard. A revoked key stops working immediately. Rotate regularly: mint a new key, update your tools, then revoke the old one. Treat keys like passwords — never put them in client-side code, mobile apps, or public repositories.

Tool configuration

Copy-paste snippets for popular tools. Compatible clients read the environment variables automatically.

Claude Code

~/Shell
export ANTHROPIC_BASE_URL=https://api.cosmosin.io
export ANTHROPIC_AUTH_TOKEN=sk-cos...
# continue as usual
claude "finish the migration"

Cursor

~/settings.json
{
"openai.baseURL": "https://api.cosmosin.io/v1",
"openai.apiKey": "sk-cos..."
}

Codex

~/config.toml
# set the key first: export COSMOSIN_API_KEY=sk-cos...
model = "deepseek-v4-flash"
model_provider = "cosmosin"
[model_providers.cosmosin]
name = "CosmosIn"
base_url = "https://api.cosmosin.io/v1"
env_key = "COSMOSIN_API_KEY"
wire_api = "responses"
On Windows: run Codex from WSL, and set COSMOSIN_API_KEY inside the WSL shell.

OpenCode

~/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"cosmosin": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://api.cosmosin.io/v1",
"apiKey": "sk-cos..."
}
}
}
}

Cline

~/Cline Settings
Provider: OpenAI Compatible
Base URL: https://api.cosmosin.io/v1
API Key: sk-cos...
Model: deepseek-v4-flash

Continue

~/config.yaml
name: CosmosIn
version: 1.0.0
schema: v1
models:
- name: CosmosIn
provider: openai
model: deepseek-v4-flash
apiBase: https://api.cosmosin.io/v1
apiKey: sk-cos...
roles:
- chat
- edit
- apply
capabilities:
- tool_use

Endpoints

MethodPathDescription
POST/v1/chat/completionsOpenAI compatible. SSE streaming supported.
POST/v1/messagesAnthropic Messages compatible.
POST/v1/responsesOpenAI Responses compatible; used by Codex CLI.
GET/v1/modelsModels your key can call.

Every endpoint uses the same key. Request bodies and responses follow the compatible OpenAI or Anthropic format — an example for /v1/chat/completions:

~/request.json
{
"model": "deepseek-v4-flash",
"messages": [
{ "role": "user", "content": "Hello!" }
]
}
~/response.json
{
"id": "chatcmpl-...",
"object": "chat.completion",
"model": "deepseek-v4-flash",
"choices": [
{
"message": { "role": "assistant", "content": "Hello! How can I help?" }
}
],
"usage": { "prompt_tokens": 9, "completion_tokens": 12, "total_tokens": 21 }
}

Streaming

Set stream: true to receive the response incrementally as Server-Sent Events (SSE). Each event carries a JSON delta in the OpenAI streaming format; the connection uses content-type text/event-stream and ends with a data: [DONE] sentinel. Most OpenAI SDKs expose streaming natively — just iterate the chunks.

~/stream.py
stream = client.chat.completions.create(
model="deepseek-v4-flash",
messages=[{"role": "user", "content": "Hello!"}],
stream=True,
)
for chunk in stream:
delta = chunk.choices[0].delta.content
if delta:
print(delta, end="", flush=True)

Models

Fill the model field with a model name from the catalog — CosmosIn uses real model names, no aliases. The full list with per-token pricing is always up to date on the pricing page; the /v1/models endpoint returns the models your key can call.

Reasoning models

Models with the Reasoning badge in the catalog spend part of their token budget thinking before answering. Control the depth per request with reasoning_effort — higher means deeper answers, more tokens, and higher latency. On non-reasoning models the parameter is ignored, so it is safe to always send. Supported levels follow each model; check the Reasoning badge in the catalog. One note: a max_tokens that is too low can leave the answer looking empty because the budget was spent thinking — raise max_tokens or drop the limit.

~/reasoning.json
{
"model": "deepseek-v4-flash",
"messages": [
{ "role": "user", "content": "Hello!" }
],
"reasoning_effort": "high"
}
EffortDepthUse for
noneOffDirect answers with no thinking
lowLightSimple tasks that need a touch of care
mediumModerateMost tasks — the sensible default
highDeepHard math, multi-step coding, planning

Embeddings

Turn text into vectors for semantic search, clustering, and retrieval-augmented generation (RAG). Compatible with the OpenAI Embeddings API: send input, receive float vectors. Embeddings do not stream — the stream flag is rejected.

~/embeddings.py
from openai import OpenAI
client = OpenAI(base_url="https://api.cosmosin.io/v1", api_key="sk-cos...")
res = client.embeddings.create(model="text-embedding-3-small", input="Hello!")
print(res.data[0].embedding[:5]) # [0.012, -0.034, 0.041, ...]

Rerank

Re-order retrieved candidates so the most relevant documents come first. Rerank uses a cross-encoder that reads the query and document together — more accurate than cosine similarity for picking the best context. The common RAG pattern: embed ±20 candidates via /v1/embeddings, rerank to top-5, then feed to chat completions.

  • query — the search text (string)
  • documents — array of candidate documents to score
  • top_n — optional; limit the number of results
  • model — the rerank model name
~/rerank.py
import requests
res = requests.post(
"https://api.cosmosin.io/v1/rerank",
headers={"Authorization": "Bearer sk-cos..."},
json={
"model": "rerank-v3",
"query": "rerank",
"documents": docs, # 10-20 kandidat
"top_n": 5,
},
)
for r in res.json()["results"]:
print(r["index"], r["relevance_score"])

Video generation

Create short MP4 clips from text or images with one endpoint. The gateway handles the async task server-side: POST returns an id with status pending (HTTP 202), then poll GET /v1/videos/{id} every ~5 seconds until status is succeeded — the response carries the download URL. Clips are stored temporarily; download promptly.

ModeHow the image is usedImages
t2vNo image — the video is generated purely from the text prompt0
i2vThe image becomes the first frame; the model animates it1
r2vImages act as subject/style references for a new scene1–3
~/t2v.sh
curl --request POST \
--url https://api.cosmosin.io/v1/videos \
--header "Authorization: Bearer sk-cos..." \
--header "Content-Type: application/json" \
--data '{
"model": "video-t2v",
"prompt": "Kota mini dari kardus hidup di malam hari",
"mode": "t2v",
"duration": 5
}'

Rate limits & quotas

Limits follow your plan. Subscription plans are governed by a per-minute request rate and a token pool; PAYG credits never expire and are bounded only by your balance. Breaching a limit returns 429 rate_limited — back off and retry after the window resets. Per-plan limits are shown on the pricing page.

Error codes

First-request errors are almost always 401 or 402: a mis-pasted key or an empty balance. Check the sk-cos prefix, then check your balance on the dashboard.

Error shape

Errors use a single, stable JSON envelope. Switch on the type field rather than parsing the message. The request_id helps correlate a failure with server logs.

~/error.json
{
"error": {
"type": "rate_limited",
"message": "Rate limit exceeded. Please retry later.",
"request_id": "req_..."
}
}
CodeErrorMeaningRecovery
400invalid_requestInvalid body; check request parameters.Diff your request body against the examples above.
401unauthorizedWrong or revoked key; check the Authorization header.Mint a new key on the dashboard if yours was revoked.
402insufficient_creditsBalance empty; top up on the dashboard.Top up via QRIS/e-wallet/VA and the balance lands instantly.
404model_not_foundUnknown model name; check the catalog.Copy the model name exactly from the pricing table.
429rate_limitedToo fast; slow down and see the Retry-After header.Follow the Retry-After header, then retry.
503all_providers_failedAll routes busy or down; automatic failover is running, retry shortly.Retry in a few seconds; report it on Telegram if it persists.

Model combos

Combos are your own virtual model ids (shaped combo/<name>) bundling 1–5 models behind one fallback strategy. The gateway tries panel models one by one within the same request: target 1 fails (402, 403, 500, timeout) → billing released → target 2, and so on. A circuit breaker skips a model during its cooldown, so a failing model costs no latency. Combos are private to their owner — another key calling your combo gets a 404. Manage them on the dashboard.

~/combo.sh
curl https://api.cosmosin.io/v1/chat/completions \
-H "Authorization: Bearer sk-cos..." \
-H "Content-Type: application/json" \
-d '{
"model": "combo/free-pack",
"messages": [{"role": "user", "content": "Halo!"}]
}'

Plans & pricing

Prices in Rupiah, transparent per token per the catalog — no hidden fees. Two ways to pay: PAYG credits (top-up, never expire) and subscription plans with a token pool. Models, prices, and plan limits are always live on the pricing page.

Docs — CosmosIn