Guide

OpenAI-compatible API quickstart: Token Factory in 3 minutes

OpenAI-compatible API, no new SDK: swap one base URL in your OpenAI client and the code you already have runs on DeepSeek V4.1 Flash, MiniMax and Qwen, free until Dec 16.

Author photo
packet.ai Team
November 24, 2026

An OpenAI-compatible API accepts the same requests as OpenAI's Chat Completions endpoint, so you can switch providers by changing the base URL and key. On packet.ai Token Factory that switch takes about 3 minutes, and tokens are free until December 16, 2026.

Key takeaways

  • Token Factory is packet.ai's OpenAI-compatible API for open-weight models.
  • Base URL: https://api.packet.ai/v1. The official OpenAI Python and Node.js SDKs work as they are.
  • Input and output tokens cost $0 until December 16, 2026.
  • Signup takes an email or Google account and one SMS code. No credit card.
  • Live models: DeepSeek V4.1 Flash, MiniMax M3.1 Flash and Qwen2.5-1.5B-Instruct. Kimi K3 is coming soon.
  • Streaming, JSON mode and tool calling use the same parameters as OpenAI.

If your code already calls OpenAI, you don't need a new SDK to try open-weight models. You need a key, a base URL and a model ID. This guide gets you from signup to a working request in about 3 minutes, then shows the same call in Python and Node.js.

Want the background on the models first? Read Token Factory is live: free LLM API for DeepSeek and MiniMax. For how the service is built, see the Token Factory deep dive.

What is an OpenAI-compatible API?

An OpenAI-compatible API is an endpoint that accepts the same request and response format as OpenAI's Chat Completions API. The JSON body, the messages array, the Authorization: Bearer header and the response shape all match. Any client written for OpenAI can call it by pointing at a different base URL.

That's why so many providers offer one. Groq, OpenRouter, Mistral and Google Gemini all expose OpenAI-compatible endpoints, and so do self-hosted servers like vLLM. Switching between them means editing two config values. The rest of your code stays the same.

What packet.ai Token Factory's OpenAI-compatible API gives you

Token Factory is packet.ai's managed LLM inference API. You send a chat completion request, packet.ai runs the model on its own GPUs and counts the tokens. You don't provision an instance or tune a serving stack, and idle time costs nothing.

OpenAI-compatible API

Chat completions through the official OpenAI Python and Node.js SDKs. Change base_url and keep your code.

Streaming, JSON mode, tools

stream=True, response_format json_object and function calling through the tools parameter.

Open-weight models

DeepSeek V4.1 Flash, MiniMax M3.1 Flash and Qwen2.5-1.5B-Instruct on packet.ai GPUs.

It runs on the same NVIDIA B200, RTX PRO 6000 and A100 fleet that packet.ai rents by the hour. If you later want a dedicated endpoint, you can rent a B200 on packet.ai and serve the same model with vLLM, which exposes the same OpenAI-compatible routes.

Make your first API call in 3 minutes

There are four steps. Setup takes about 90 seconds and the request takes about 90 more.

1

Create your packet.ai account (30 sec)

Sign up at dash.packet.ai with an email address or a Google account. No card needed.

2

Verify your phone number (30 sec)

Enter the SMS code. Unverified accounts can't send requests.

3

Pick a model and create an API key (30 sec)

Copy a model ID from dash.packet.ai/serverless, create a key and save it as PACKET_API_KEY.

4

Send your first request (90 sec)

POST to https://api.packet.ai/v1/chat/completions with curl or the OpenAI SDK.

Step 1: Create your packet.ai account

Sign up at dash.packet.ai with an email address or a Google account. You won't be asked for a card.

Step 2: Verify your phone number

Enter the code sent by SMS. Requests from unverified accounts are rejected, so finish this before you create a key.

Note

If your first request returns 401 and the key looks right, check that phone verification went through.

Step 3: Pick a model and create an API key

Open the Serverless models page at dash.packet.ai/serverless, choose a model and copy its model ID. Then create an API key and save it as an environment variable. Keep it out of your source code and out of git.

Step 4: Send a request with curl

Paste this into a terminal with your key and the model ID from step 3:

Terminal
export PACKET_API_KEY="your-api-key"

curl https://api.packet.ai/v1/chat/completions \
  -H "Authorization: Bearer $PACKET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "DeepSeek-V4.1-Flash-NVFP4",
    "messages": [{"role": "user", "content": "Explain KV cache in one sentence."}]
  }'

A successful call returns the standard OpenAI response format (trimmed here):

Response (JSON)
{
  "object": "chat.completion",
  "model": "DeepSeek-V4.1-Flash-NVFP4",
  "choices": [{
    "index": 0,
    "message": {"role": "assistant", "content": "The KV cache stores attention keys and values..."},
    "finish_reason": "stop"
  }],
  "usage": {"prompt_tokens": 14, "completion_tokens": 31, "total_tokens": 45}
}

Token Factory charges $0 per input and output token until December 16, 2026.

Switch from OpenAI to an OpenAI-compatible API in two lines

If you already use the OpenAI SDK, add base_url and swap the key. Everything else stays the same, which makes Token Factory a low-effort OpenAI API alternative for open-weight models.

Python
from openai import OpenAI

# Before: OpenAI
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])

# After: packet.ai Token Factory
client = OpenAI(
    base_url="https://api.packet.ai/v1",
    api_key=os.environ["PACKET_API_KEY"],
)

Moving a production app? The guide to migrating to an OpenAI-compatible endpoint covers testing, fallbacks and the behaviour differences to watch for.

Python (OpenAI SDK)

Install the SDK with pip install openai, then run:

Python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.packet.ai/v1",
    api_key=os.environ["PACKET_API_KEY"],
)

resp = client.chat.completions.create(
    model="DeepSeek-V4.1-Flash-NVFP4",
    messages=[{"role": "user", "content": "Summarise this ticket in one line: login fails after password reset."}],
)
print(resp.choices[0].message.content)

Node.js (OpenAI SDK)

Install the SDK with npm install openai, then run:

JavaScript (Node.js)
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.packet.ai/v1",
  apiKey: process.env.PACKET_API_KEY,
});

const resp = await client.chat.completions.create({
  model: "DeepSeek-V4.1-Flash-NVFP4",
  messages: [{ role: "user", content: "Summarise this ticket in one line: login fails after password reset." }],
});
console.log(resp.choices[0].message.content);

Streaming, JSON mode and tool calling on Token Factory

All three use OpenAI's parameter names, so code that already uses them keeps working.

Streaming responses

Set stream=True to get tokens as they're generated. It helps in chat interfaces, where the first token matters more than the total time.

Python
stream = client.chat.completions.create(
    model="DeepSeek-V4.1-Flash-NVFP4",
    messages=[{"role": "user", "content": "List three uses for a 1.5B model."}],
    stream=True,
)
for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="")

JSON mode

Set response_format to json_object when another program reads the output. Validate the result anyway.

Python
resp = client.chat.completions.create(
    model="DeepSeek-V4.1-Flash-NVFP4",
    response_format={"type": "json_object"},
    messages=[{"role": "user", "content": "Return JSON with keys gpu and vram_gb for the B200."}],
)

Tool calling

Pass your functions in tools. The model replies with tool_calls for your code to run.

Python
tools = [{
    "type": "function",
    "function": {
        "name": "get_gpu_price",
        "description": "Get the hourly price of a GPU on packet.ai",
        "parameters": {
            "type": "object",
            "properties": {"gpu": {"type": "string"}},
            "required": ["gpu"],
        },
    },
}]

resp = client.chat.completions.create(
    model="DeepSeek-V4.1-Flash-NVFP4",
    messages=[{"role": "user", "content": "How much is a B200 per hour?"}],
    tools=tools,
)
print(resp.choices[0].message.tool_calls)

Which open source LLM API model should you call first?

All three live models are free until December 16. After that the output price differs by up to 8.5×, so it's worth matching the model to the job now.

ModelContextBest forInput / output per 1M tokens after Dec 16
DeepSeek V4.1 Flash (NVFP4)131KReasoning, coding, long documents$0.23 / $0.85
MiniMax M3.1 Flash131KAgents, coding, general chat at lower cost$0.15 / $0.60
Qwen2.5-1.5B-Instruct33KClassification, extraction, high-volume simple tasks$0.10 / $0.10
Kimi K3n/aComing soonn/a

Good fit for Token Factory today

  • Prototypes and evals that need real request volume
  • Internal tools and side projects without a billing setup
  • Comparing DeepSeek, MiniMax and Qwen on the same prompt

Plan for change

  • Per-token pricing starts on December 16, 2026
  • The model list will change, so keep the model ID in config
  • No public rate limit is published yet, so check your dashboard

After the free period, Qwen2.5-1.5B-Instruct on Token Factory costs $0.10 per million input tokens and $0.10 per million output tokens.

How Token Factory compares to other free LLM APIs

Groq, OpenRouter and Google Gemini also offer free access through OpenAI-compatible endpoints. Most permanent free tiers cap requests per day. Token Factory charges nothing per token for a fixed period instead.

ProviderFree allowanceCard requiredOpenAI-compatible base URL
packet.ai Token Factory$0 for all tokens until Dec 16, 2026No (phone verification)https://api.packet.ai/v1
Groq30 RPM, 1K requests/day, 200K tokens/day on gpt-oss-120bNohttps://api.groq.com/openai/v1
OpenRouter (:free models)20 RPM, 50 requests/day (1,000 after buying 10 credits)Nohttps://openrouter.ai/api/v1
Google Gemini APIFree tier on Flash models; limits shown in AI StudioNohttps://generativelanguage.googleapis.com/v1beta/openai/

Groq's free tier allows 1,000 requests and 200,000 tokens a day on gpt-oss-120b. OpenRouter's free models allow 50 requests a day.

Pick Groq or Gemini if a permanent, rate-limited tier fits your workload. Pick Token Factory if you want to send real volume now and keep the same endpoint once you start paying. Competitor limits come from each provider's documentation as of October 2026 and change often.

Fix common errors on your first OpenAI-compatible API call

ErrorLikely causeFix
401 UnauthorizedMissing or wrong key, or phone not verifiedCheck the Authorization: Bearer header and finish SMS verification
404 Not FoundWrong path or model IDUse https://api.packet.ai/v1/chat/completions and copy the model ID from dash.packet.ai/serverless
Connection or SSL errorBase URL typo or missing /v1Set base_url to exactly https://api.packet.ai/v1
429 Too Many RequestsRate limit on your keyBack off and retry with an exponential delay, or ask help@packet.ai for higher limits
400 Bad RequestPrompt too long or invalid JSONTrim the prompt below the model's context window and validate the request body

Frequently asked questions

Yes, until December 16, 2026. Every input and output token on packet.ai Token Factory costs $0 until then, for new and existing accounts. After that date, input and output tokens are billed separately per million at each model's listed rate. Idle time is never charged.
No. You need an email address or Google account and a phone number that can receive one SMS code. Phone verification has to be done before your first request goes through. No card is collected during the free period, so you can test the API before you set up billing.
Yes. Token Factory follows the OpenAI Chat Completions format, so the official OpenAI Python and Node.js SDKs work without changes. Set base_url to https://api.packet.ai/v1, pass your packet.ai API key and use a Token Factory model ID. Streaming, JSON mode and tool calling take the same parameters as on OpenAI.
DeepSeek V4.1 Flash (NVFP4), MiniMax M3.1 Flash and Qwen2.5-1.5B-Instruct are live, and Kimi K3 is listed as coming soon. All of them run on packet.ai's own GPUs. The Serverless models page in the dashboard shows the current list, each model's context window and the exact model ID to use.
Your key, code and endpoint keep working. From December 16, 2026, tokens are billed per million: DeepSeek V4.1 Flash at $0.23 input and $0.85 output, MiniMax M3.1 Flash at $0.15 and $0.60, and Qwen2.5-1.5B-Instruct at $0.10 for both. Prices follow the market average for each model as of November 2026.
Yes. You can rent a B200, RTX PRO 6000 or A100 on packet.ai by the hour and serve the same model with vLLM. vLLM exposes the same OpenAI-compatible routes, so moving from Token Factory to your own GPU means changing the base URL again.

Last reviewed: 24 November 2026. Ready to make your first call? Get a free Token Factory API key, or browse cluster options to serve the same models on your own GPU.

Waste less compute.

Same models. Same API. Fraction of the cost. Start free — no credit card required.

Start building →

More from the blog