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">&quot;Authorization: Bearer sk-xxxx&quot;</span> \
  -H <span class="hljs-string">&quot;Content-Type: application/json&quot;</span> \
  -d <span class="hljs-string">&#x27;{
    &quot;model&quot;: &quot;deepseek:deepseek-chat&quot;,
    &quot;messages&quot;: [
      {&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: &quot;Hi, just reply with \&quot;Hi\&quot;&quot;}
    ],
    &quot;temperature&quot;: 0.7,
    &quot;max_tokens&quot;: 128,
    &quot;stream&quot;: false
  }&#x27;</span>

Sample response

<span class="hljs-punctuation">{</span>
  <span class="hljs-attr">&quot;id&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;1a9f9f27-ef53-4b0e-8849-465bf8270314&quot;</span><span class="hljs-punctuation">,</span>
  <span class="hljs-attr">&quot;object&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;chat.completion&quot;</span><span class="hljs-punctuation">,</span>
  <span class="hljs-attr">&quot;created&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-number">1772183892</span><span class="hljs-punctuation">,</span>
  <span class="hljs-attr">&quot;model&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;deepseek:deepseek-chat&quot;</span><span class="hljs-punctuation">,</span>
  <span class="hljs-attr">&quot;choices&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>
    <span class="hljs-punctuation">{</span>
      <span class="hljs-attr">&quot;index&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-number">0</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">&quot;message&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
        <span class="hljs-attr">&quot;role&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;assistant&quot;</span><span class="hljs-punctuation">,</span>
        <span class="hljs-attr">&quot;content&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;Hi&quot;</span>
      <span class="hljs-punctuation">}</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">&quot;finish_reason&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;stop&quot;</span>
    <span class="hljs-punctuation">}</span>
  <span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span>
  <span class="hljs-attr">&quot;usage&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
    <span class="hljs-attr">&quot;prompt_tokens&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-number">8</span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">&quot;completion_tokens&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-number">1</span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">&quot;total_tokens&quot;</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 model field uses the provider:modelId format (for example deepseek: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">&quot;Authorization: Bearer sk-xxxx&quot;</span> \
  -H <span class="hljs-string">&quot;Content-Type: application/json&quot;</span> \
  -N \
  -d <span class="hljs-string">&#x27;{
    &quot;model&quot;: &quot;deepseek:deepseek-chat&quot;,
    &quot;messages&quot;: [
      {&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: &quot;Introduce yourself in one sentence&quot;}
    ],
    &quot;temperature&quot;: 0.7,
    &quot;max_tokens&quot;: 256,
    &quot;stream&quot;: true
  }&#x27;</span>

Typical SSE chunks:

data: {&quot;id&quot;:&quot;...&quot;,&quot;object&quot;:&quot;chat.completion.chunk&quot;,&quot;choices&quot;:[{&quot;delta&quot;:{&quot;content&quot;:&quot;Hi&quot;}}], ...}

data: {&quot;id&quot;:&quot;...&quot;,&quot;object&quot;:&quot;chat.completion.chunk&quot;,&quot;choices&quot;:[{&quot;delta&quot;:{&quot;content&quot;:&quot;, I&#x27;m ApiSet.ai Gateway.&quot;}}], ...}

data: {&quot;id&quot;:&quot;...&quot;,&quot;object&quot;:&quot;chat.completion.chunk&quot;,&quot;choices&quot;:[{&quot;delta&quot;:{&quot;content&quot;:&quot;&quot;},&quot;finish_reason&quot;:&quot;stop&quot;}],
       &quot;usage&quot;:{&quot;prompt_tokens&quot;:13,&quot;completion_tokens&quot;:10,&quot;total_tokens&quot;: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">&quot;https://apiset.ai/api/v1/chat/completions&quot;</span>, {
  <span class="hljs-attr">method</span>: <span class="hljs-string">&quot;POST&quot;</span>,
  <span class="hljs-attr">headers</span>: {
    <span class="hljs-string">&quot;Authorization&quot;</span>: <span class="hljs-string">&quot;Bearer sk-xxxx&quot;</span>,
    <span class="hljs-string">&quot;Content-Type&quot;</span>: <span class="hljs-string">&quot;application/json&quot;</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">&quot;deepseek:deepseek-chat&quot;</span>,
    <span class="hljs-attr">messages</span>: [{ <span class="hljs-attr">role</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-attr">content</span>: <span class="hljs-string">&quot;Hi&quot;</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 = &quot;https://apiset.ai/api/v1/chat/completions&quot;
headers = {
    &quot;Authorization&quot;: &quot;Bearer sk-xxxx&quot;,
    &quot;Content-Type&quot;: &quot;application/json&quot;,
}
json_data = {
    &quot;model&quot;: &quot;deepseek:deepseek-chat&quot;,
    &quot;messages&quot;: [{&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: &quot;Hi&quot;}],
    &quot;stream&quot;: False,
}

resp = requests.post(url, headers=headers, json=json_data, timeout=30)
data = resp.json()
print(data[&quot;choices&quot;][0][&quot;message&quot;][&quot;content&quot;])

Error format

The gateway uses an OpenAI‑style error envelope, for example:

<span class="hljs-punctuation">{</span>
  <span class="hljs-attr">&quot;error&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
    <span class="hljs-attr">&quot;message&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;Incorrect API key provided. For details&quot;</span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">&quot;type&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;invalid_request_error&quot;</span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">&quot;param&quot;</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">&quot;code&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;invalid_api_key&quot;</span>
  <span class="hljs-punctuation">}</span><span class="hljs-punctuation">,</span>
  <span class="hljs-attr">&quot;request_id&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;9f6b3bb8-9328-91ad-a5b7-1feed430211b&quot;</span>
<span class="hljs-punctuation">}</span>

Common error codes:

  • invalid_api_key: API key does not exist or is invalid.
  • model_not_found: The requested model is not configured in the gateway.
  • insufficient_quota: Account balance or quota is insufficient.