OriginCoder

DeepSeek API Through an OpenAI-Compatible Gateway: Python, Node and curl

Published 2026-11-11

DeepSeek models can be called through any gateway that exposes them in the OpenAI Chat Completions format, which means you can use the standard OpenAI SDK and change two settings: the Base URL and the key. This guide shows how to do that with OriginCoder, the AI API gateway, in Python, Node.js and curl. If you searched for "DeepSeek API", the short version is: create a key in a DeepSeek group, point your OpenAI client at https://origincoder.com/v1, and pass a DeepSeek model name.

Disclosure: we run OriginCoder, so we have a stake in the gateway route. You can also use DeepSeek's own API directly; the code below works the same way with DeepSeek's own Base URL and key, so you can compare. Information here is current as of November 2026.

Which model name to use

Use the exact model name shown for DeepSeek in the console's model plaza. We do not list names here, because the set of DeepSeek models and their names change as DeepSeek releases new versions, and the live list on the model pricing page is the source of truth. The examples use your-deepseek-model as a placeholder. Replace it with a name copied from that page.

What you need

  • An OriginCoder account with a balance. Create an account.
  • An API key in a group that serves DeepSeek models. The group decides which models the key can call. A key from a Claude-only group will answer "model not found" for DeepSeek names.
  • Any OpenAI-compatible client: the official OpenAI SDK for Python or Node.js, or plain HTTP.

curl

curl https://origincoder.com/v1/chat/completions \
  -H "Authorization: Bearer sk-xxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "your-deepseek-model",
    "messages": [{"role": "user", "content": "Explain what a mutex is in two sentences."}]
  }'

Python

from openai import OpenAI

client = OpenAI(
    base_url="https://origincoder.com/v1",
    api_key="sk-xxxx",
)

resp = client.chat.completions.create(
    model="your-deepseek-model",
    messages=[{"role": "user", "content": "Explain what a mutex is in two sentences."}],
)
print(resp.choices[0].message.content)

Node.js

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://origincoder.com/v1",
  apiKey: "sk-xxxx",
});

const resp = await client.chat.completions.create({
  model: "your-deepseek-model",
  messages: [{ role: "user", content: "Explain what a mutex is in two sentences." }],
});
console.log(resp.choices[0].message.content);

Do not hard-code real keys. Read them from an environment variable such as process.env.ORIGINCODER_API_KEY or os.environ["ORIGINCODER_API_KEY"].

Streaming

Set stream=True (Python) or stream: true (Node.js) and iterate over the chunks, exactly as with the OpenAI API.

Reasoning models

Some DeepSeek models return their reasoning separately from the final answer. Whether and how a gateway passes that field through depends on the model and the gateway version, so test with your model and look at the raw response before writing code that depends on it.

Why call DeepSeek through a gateway

  • One key for several providers. Your code can switch between DeepSeek, Claude, GPT or Gemini by changing the model name, with one balance. See AI gateway explained for when this matters.
  • Per-request records. Each call appears in the console's usage page with token counts and cost.
  • Billing in one place, instead of a separate account with each provider.

The trade-offs are the usual ones for a gateway: your prompts pass through a third party, and a gateway can lag behind a provider's newest features. For the full list of what to weigh, read the LLM gateway comparison.

Troubleshooting

Symptom Likely cause Fix
401 or "invalid API key" Wrong or disabled key Copy it again from the console
404 Base URL is missing /v1, or has it twice Use https://origincoder.com/v1 for OpenAI clients
"model not found" or 403 The key's group does not serve that model, or the name is misspelled Copy the name from the model pricing page and use a key from a DeepSeek group
429 Rate limit Retry with backoff, and check your key's limits in the console
Balance errors No balance Top up in the console

Prices and safety

DeepSeek's per-token prices on OriginCoder are shown on the model pricing page, and may differ from DeepSeek's own prices, so compare before you commit. Read the terms to see how your data is handled, and avoid sending secrets. OriginCoder is independent and not affiliated with DeepSeek.

Using a coding agent instead of raw API calls? See How to use Claude Code with a custom API endpoint and How to use Codex CLI with a custom API endpoint.

All guides

More guides