ApiSet.ai Gateway · Quickstart
Overview
ApiSet.ai Gateway exposes an OpenAI‑compatible HTTP API so that you can access multiple model providers (DeepSeek, OpenAI, etc.) through a single entrypoint.
- Base URL:
https://apiset.ai/api/v1 - Chat Completions:
POST /chat/completions - Auth:
Authorization: Bearer {api_set_key} - Protocol: Largely compatible with OpenAI
chat/completions
Getting an API Key
- Sign up and sign in on the ApiSet.ai console.
- Open API Key Management and create a new key.
- Copy the generated
sk-...string. - Use it in requests via the
Authorization: Bearer {api_set_key}header.
Security tip: Never hardcode your API key in frontend code or public repos. Store it in backend configuration or secure environment variables.
Non‑streaming request example
curl https://apiset.ai/api/v1/chat/completions \
-H <span class="hljs-string">"Authorization: Bearer sk-xxxx"</span> \
-H <span class="hljs-string">"Content-Type: application/json"</span> \
-d <span class="hljs-string">'{
"model": "deepseek:deepseek-chat",
"messages": [
{"role": "user", "content": "Hi, just reply with \"Hi\""}
],
"temperature": 0.7,
"max_tokens": 128,
"stream": false
}'</span>
Sample response
<span class="hljs-punctuation">{</span>
<span class="hljs-attr">"id"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"1a9f9f27-ef53-4b0e-8849-465bf8270314"</span><span class="hljs-punctuation">,</span>
<span class="hljs-attr">"object"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"chat.completion"</span><span class="hljs-punctuation">,</span>
<span class="hljs-attr">"created"</span><span class="hljs-punctuation">:</span> <span class="hljs-number">1772183892</span><span class="hljs-punctuation">,</span>
<span class="hljs-attr">"model"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"deepseek:deepseek-chat"</span><span class="hljs-punctuation">,</span>
<span class="hljs-attr">"choices"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>
<span class="hljs-punctuation">{</span>
<span class="hljs-attr">"index"</span><span class="hljs-punctuation">:</span> <span class="hljs-number">0</span><span class="hljs-punctuation">,</span>
<span class="hljs-attr">"message"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
<span class="hljs-attr">"role"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"assistant"</span><span class="hljs-punctuation">,</span>
<span class="hljs-attr">"content"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Hi"</span>
<span class="hljs-punctuation">}</span><span class="hljs-punctuation">,</span>
<span class="hljs-attr">"finish_reason"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"stop"</span>
<span class="hljs-punctuation">}</span>
<span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span>
<span class="hljs-attr">"usage"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
<span class="hljs-attr">"prompt_tokens"</span><span class="hljs-punctuation">:</span> <span class="hljs-number">8</span><span class="hljs-punctuation">,</span>
<span class="hljs-attr">"completion_tokens"</span><span class="hljs-punctuation">:</span> <span class="hljs-number">1</span><span class="hljs-punctuation">,</span>
<span class="hljs-attr">"total_tokens"</span><span class="hljs-punctuation">:</span> <span class="hljs-number">9</span>
<span class="hljs-punctuation">}</span>
<span class="hljs-punctuation">}</span>
Note: In requests, the
modelfield uses theprovider:modelIdformat (for exampledeepseek:deepseek-chat). The gateway parses this and routes the call to the correct upstream model.
Streaming request example
curl https://apiset.ai/api/v1/chat/completions \
-H <span class="hljs-string">"Authorization: Bearer sk-xxxx"</span> \
-H <span class="hljs-string">"Content-Type: application/json"</span> \
-N \
-d <span class="hljs-string">'{
"model": "deepseek:deepseek-chat",
"messages": [
{"role": "user", "content": "Introduce yourself in one sentence"}
],
"temperature": 0.7,
"max_tokens": 256,
"stream": true
}'</span>
Typical SSE chunks:
data: {"id":"...","object":"chat.completion.chunk","choices":[{"delta":{"content":"Hi"}}], ...}
data: {"id":"...","object":"chat.completion.chunk","choices":[{"delta":{"content":", I'm ApiSet.ai Gateway."}}], ...}
data: {"id":"...","object":"chat.completion.chunk","choices":[{"delta":{"content":""},"finish_reason":"stop"}],
"usage":{"prompt_tokens":13,"completion_tokens":10,"total_tokens":23}}
The usage field in the final chunk is used for billing and usage statistics.
Language SDK examples
JavaScript (Node.js, fetch)
<span class="hljs-keyword">const</span> resp = <span class="hljs-keyword">await</span> <span class="hljs-title function_">fetch</span>(<span class="hljs-string">"https://apiset.ai/api/v1/chat/completions"</span>, {
<span class="hljs-attr">method</span>: <span class="hljs-string">"POST"</span>,
<span class="hljs-attr">headers</span>: {
<span class="hljs-string">"Authorization"</span>: <span class="hljs-string">"Bearer sk-xxxx"</span>,
<span class="hljs-string">"Content-Type"</span>: <span class="hljs-string">"application/json"</span>
},
<span class="hljs-attr">body</span>: <span class="hljs-title class_">JSON</span>.<span class="hljs-title function_">stringify</span>({
<span class="hljs-attr">model</span>: <span class="hljs-string">"deepseek:deepseek-chat"</span>,
<span class="hljs-attr">messages</span>: [{ <span class="hljs-attr">role</span>: <span class="hljs-string">"user"</span>, <span class="hljs-attr">content</span>: <span class="hljs-string">"Hi"</span> }],
<span class="hljs-attr">stream</span>: <span class="hljs-literal">false</span>
})
});
<span class="hljs-keyword">const</span> data = <span class="hljs-keyword">await</span> resp.<span class="hljs-title function_">json</span>();
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(data.<span class="hljs-property">choices</span>[<span class="hljs-number">0</span>].<span class="hljs-property">message</span>.<span class="hljs-property">content</span>);
Python (requests)
import requests
url = "https://apiset.ai/api/v1/chat/completions"
headers = {
"Authorization": "Bearer sk-xxxx",
"Content-Type": "application/json",
}
json_data = {
"model": "deepseek:deepseek-chat",
"messages": [{"role": "user", "content": "Hi"}],
"stream": False,
}
resp = requests.post(url, headers=headers, json=json_data, timeout=30)
data = resp.json()
print(data["choices"][0]["message"]["content"])
Error format
The gateway uses an OpenAI‑style error envelope, for example:
<span class="hljs-punctuation">{</span>
<span class="hljs-attr">"error"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
<span class="hljs-attr">"message"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Incorrect API key provided. For details"</span><span class="hljs-punctuation">,</span>
<span class="hljs-attr">"type"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"invalid_request_error"</span><span class="hljs-punctuation">,</span>
<span class="hljs-attr">"param"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">null</span></span><span class="hljs-punctuation">,</span>
<span class="hljs-attr">"code"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"invalid_api_key"</span>
<span class="hljs-punctuation">}</span><span class="hljs-punctuation">,</span>
<span class="hljs-attr">"request_id"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"9f6b3bb8-9328-91ad-a5b7-1feed430211b"</span>
<span class="hljs-punctuation">}</span>
Common error codes:
invalid_api_key: API key does not exist or is invalid.model_not_found: The requestedmodelis not configured in the gateway.insufficient_quota: Account balance or quota is insufficient.