thelastapi
Get started free

An OpenAI-compatible endpoint for DeepSeek and Qwen

Use an OpenAI-compatible endpoint at /v1/ai to run DeepSeek and Qwen models with standard OpenAI SDKs, exact model routing, and per-call costs.

On this page 7 sections

You can call both DeepSeek and Qwen through an OpenAI-compatible endpoint by pointing standard OpenAI client libraries to /v1/ai on thelastapi. Set your base URL to the gateway, supply your API key, and specify the model name in your chat completion request. Exactly the model you request is executed without silent fallbacks, and every response includes the actual token cost.

Using models from multiple labs usually forces you to juggle separate account dashboards, billing systems, and client libraries. By routing your requests through an OpenAI-compatible gateway, you use existing tools and codebases while accessing open-weight architectures like DeepSeek and Qwen alongside proprietary offerings.

How to route requests to DeepSeek and Qwen

The thelastapi gateway accepts requests at POST /v1/ai/chat/completions. You specify models in one of two ways: using a purpose-built tier name or using a direct lab model identifier.

For DeepSeek, the tier name is vibiz/lite. This route maps directly to DeepSeek V4.1 Flash, providing a 1,000,000 token context window. If you want specific versions or direct lab builds of DeepSeek or Qwen, you provide the full model identifier from the catalog of over 400 supported language models.

Model identifierUnderlying enginePrimary use casePrice per million tokens (in / out)
vibiz/liteDeepSeek V4.1 FlashHigh-volume chat, 1M context$0.14 / $0.42
vibiz/fastGPT-6 LunaFast chat, tool calls, JSON$0.10 / $0.50
vibiz/smartClaude Sonnet 5.5Coding, writing, multi-step agents$2.00 / $10.00
Lab catalog (e.g., DeepSeek, Qwen)Named lab modelDirect access by lab idLab list price + AI fee

When you send a request, the platform routes it specifically to that model. If the target provider or model experiences downtime, the gateway returns a 503 error (model_unavailable or provider_unavailable) with a retry hint. It never swaps in a different model without your knowledge.

Calling DeepSeek and Qwen with the OpenAI SDK

Because the gateway adheres to the standard chat completions schema, you can use the official openai package directly.

When you create a project and add the AI resource using the vibiz CLI, your local environment receives VIBIZ_AI_BASE_URL and VIBIZ_AI_API_KEY. The platform also sets the standard OPENAI_BASE_URL and OPENAI_API_KEY environment variables automatically.

Here is how to run queries against vibiz/lite and a specific Qwen model using TypeScript:

TypeScript
import OpenAI from 'openai';

const openai = new OpenAI({
  baseURL: process.env.VIBIZ_AI_BASE_URL,
  apiKey: process.env.VIBIZ_AI_API_KEY,
});

async function main() {
  // Call DeepSeek via the vibiz/lite tier
  const deepseekResponse = await openai.chat.completions.create({
    model: 'vibiz/lite',
    messages: [
      { role: 'system', content: 'You are a precise technical writer.' },
      { role: 'user', content: 'Explain what a bloom filter does in one paragraph.' },
    ],
  });

  console.log('DeepSeek response:', deepseekResponse.choices[0]?.message.content);

  // Call Qwen directly by its catalog model id
  const qwenResponse = await openai.chat.completions.create({
    model: 'qwen/qwen-2.5-72b-instruct',
    messages: [
      { role: 'user', content: 'Write a bash script that checks if port 8080 is open.' },
    ],
  });

  console.log('Qwen response:', qwenResponse.choices[0]?.message.content);
}

main();

If your application uses the platform framework package @vibiz/app, you can pass vibiz.ai directly into the client constructor:

TypeScript
import OpenAI from 'openai';
import { vibiz } from '@vibiz/app';

const openai = new OpenAI(vibiz.ai);

For more details on connecting different frameworks to the gateway, see OpenAI-compatible API for Claude and Gemini: change one base URL and Use @ai-sdk/openai with Claude, Gemini and more.

Testing from the CLI or plain HTTP

You do not need to write application code to inspect models or test responses. The vibiz CLI lets you search the catalogue and test completions directly from your terminal.

To search for available DeepSeek and Qwen models in the catalogue:

Terminal
vibiz ai models deepseek
vibiz ai models qwen

To run a streaming prompt from your terminal using vibiz/lite:

Terminal
vibiz ai "Summarize the differences between TCP and UDP in two bullets." --model vibiz/lite

You can also make raw HTTP calls using curl. This makes it simple to integrate DeepSeek or Qwen into shell scripts, CI pipelines, or languages without dedicated libraries:

Terminal
curl https://thelastapi.dev/v1/ai/chat/completions \
  -H "Authorization: Bearer $VIBIZ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "vibiz/lite",
    "messages": [
      {"role": "user", "content": "Return a JSON array containing three colors."}
    ],
    "response_format": {"type": "json_object"}
  }'

The gateway supports standard features including JSON mode, streaming via Server-Sent Events (SSE), and tool calling. If an invalid model name is passed, the gateway responds with HTTP 400 invalid_request and sets param: "model".

Inspecting model costs and metadata

Most unified APIs return a standard OpenAI response shape that hides infrastructure details. thelastapi preserves the standard fields while appending operational metadata to every JSON response:

  • served_model: Confirms the exact model identifier that executed the call.
  • cost_micro_usd: Shows the real cost of the request in millionths of a dollar.

A typical response payload looks like this:

JSON
{
  "id": "chatcmpl_8923bc71",
  "object": "chat.completion",
  "created": 1730000000,
  "model": "vibiz/lite",
  "served_model": "deepseek-v4.1-flash",
  "cost_micro_usd": 14,
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "A Bloom filter is a space-efficient probabilistic data structure..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 42,
    "completion_tokens": 58,
    "total_tokens": 100
  }
}

Calls are billed against your prepaid credits balance at cost plus a 10% platform margin. Detailed ledger entries are generated for every call and can be reviewed via vibiz usage --by model or within the web dashboard. For a broader look at managing model accounts, read One API key for GPT, Claude and Gemini: how a unified AI API works.

Setting safety budgets and limits

To protect your balance from unexpected loops or heavy usage spikes, the platform provides hard budgeting tools:

  1. Daily account spend ceiling: New accounts have a default limit of $5 per UTC day across AI and system actions. Account owners can raise this up to $1,000 in the dashboard or via PATCH /v1/billing.
  2. Project AI budgets: Projects default to a $1 daily AI budget. You can adjust this with the CLI:
    Terminal
    vibiz ai budget 15 --project prj_123
  3. End-user attribution: Pass a stable pseudonymous user identifier using the user property in the chat completion body or via the X-Vibiz-User header. The system tracks consumption per user and enforces any configured end_user_daily_budget_usd.

When a request exceeds a budget or limit, the API returns HTTP 429 rate_limited with a clear explanation in details.reason (such as project_budget or daily_spend). The error response includes a raise_url directing the project owner to the specific dashboard field needed to lift the limit.

Review the Usage and limits guide and Billing and credits reference for more information on managing spend.

Rate limits and error formats

Default throughput limits depend on the type of key you use:

  • Account key (vz_sk_...): 300 requests and 400,000 tokens per minute, with up to 50 concurrent requests.
  • Project AI key (vz_ai_...): 120 requests and 200,000 tokens per minute, with up to 25 concurrent requests (configurable up to 600 requests and 2,000,000 tokens per minute).

When you do encounter errors, they follow the standard OpenAI format:

JSON
{
  "error": {
    "code": "rate_limited",
    "message": "Project daily AI budget exceeded.",
    "type": "requests",
    "param": null,
    "details": {
      "reason": "project_budget",
      "limit_usd": 1,
      "spent_usd": 1.02
    }
  }
}

If an error occurs mid-stream during an SSE session, it is transmitted as the final event (data: {"error": {...}}) without an accompanying [DONE] indicator, allowing standard client libraries to surface the exception cleanly. You can learn more about managing environments and security policies in Keys and environments.

To explore the complete parameter list, supported modalities, and additional model families, read the comprehensive AI docs.

Frequently asked questions

Can I use tool calling and JSON mode with DeepSeek and Qwen through this endpoint?

Yes. The gateway translates standard OpenAI tool definitions and JSON mode directives into the native parameters required by DeepSeek and Qwen.

What happens if DeepSeek or Qwen is temporarily down?

The API returns an HTTP 503 error with a `model_unavailable` or `provider_unavailable` code and a retry hint. The gateway never silently routes your request to a different model.

How do I track spending for DeepSeek and Qwen separately from other models?

Run `vibiz usage --by model` in your terminal or inspect the `served_model` and `cost_micro_usd` fields returned in the JSON response of each call.

What is the maximum token output supported for chat completions?

When `max_tokens` is omitted, requests default to 1,024 tokens. You can set it up to 16,384 tokens, depending on the model's supported limit.