OpenAI-compatible API. Use your existing SDK — just change the base URL.
https://api.tunanapi.com/v1from openai import OpenAI client = OpenAI( api_key="sk-YOUR_API_KEY", base_url="https://api.tunanapi.com/v1" ) response = client.chat.completions.create( model="deepseek-chat", messages=[{"role": "user", "content": "Hello!"}] ) print(response.choices[0].message.content)
curl https://api.tunanapi.com/v1/chat/completions \ -H "Authorization: Bearer sk-YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "deepseek-chat", "messages": [{"role": "user", "content": "Hello!"}] }'
import OpenAI from 'openai'; const client = new OpenAI({ apiKey: 'sk-YOUR_API_KEY', baseURL: 'https://api.tunanapi.com/v1' }); const response = await client.chat.completions.create({ model: 'deepseek-chat', messages: [{ role: 'user', content: 'Hello!' }] }); console.log(response.choices[0].message.content);
Include your API key in the Authorization header:
Authorization: Bearer sk-YOUR_API_KEY
Get your API key at tunanapi.com — sign up with email and top up credits. New accounts get $0.50 free.
All prices per 1M tokens. Input = prompt tokens, Output = completion tokens.
| Model | Provider | Input | Output | Context |
|---|---|---|---|---|
| deepseek-chat | DeepSeek | $0.20 | $0.40 | 128K |
| deepseek-reasoner | DeepSeek | $2.50 | $5.00 | 128K |
| qwen3.7-max | Qwen | $1.80 | $5.40 | 128K |
| qwen3.7-plus | Qwen | $0.58 | $1.74 | 128K |
| qwen3.5-flash | Qwen | $0.07 | $0.22 | 128K |
| glm-4-plus | GLM | $1.80 | $5.40 | 128K |
| glm-4-flash | GLM | $0.07 | $0.22 | 128K |
| minimax-m2.5 | MiniMax | $0.22 | $1.65 | 197K |
| minimax-m2.7 | MiniMax | $0.29 | $1.73 | 205K |
| minimax-m3 | MiniMax | $0.43 | $3.31 | 1M |
deepseek-chat for general tasks, deepseek-reasoner for complex reasoning, qwen3.5-flash or glm-4-flash for fast & cheap, and minimax-m3 for long-context (1M tokens).
Create a chat completion. Compatible with OpenAI's chat completions API.
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID (see table above) |
messages | array | Yes | Array of message objects with role and content |
temperature | number | No | 0-2, default 1. Higher = more random |
max_tokens | integer | No | Max tokens in completion |
stream | boolean | No | Stream partial results (SSE) |
top_p | number | No | Nucleus sampling, default 1 |
from openai import OpenAI client = OpenAI( api_key="sk-YOUR_API_KEY", base_url="https://api.tunanapi.com/v1" ) stream = client.chat.completions.create( model="deepseek-chat", messages=[{"role": "user", "content": "Write a haiku about coding"}], stream=True ) for chunk in stream: if chunk.choices[0].delta.content: print(chunk.choices[0].delta.content, end="")
| Code | Type | Description |
|---|---|---|
| 400 | Bad Request | Invalid parameters or malformed request |
| 401 | Unauthorized | Invalid or missing API key |
| 402 | Insufficient Quota | Not enough credits. Top up at tunanapi.com |
| 404 | Not Found | Model not available or endpoint doesn't exist |
| 429 | Rate Limited | Too many requests. Slow down or contact us |
| 500 | Server Error | Internal error. Retry after a moment |
| 503 | Service Unavailable | Upstream provider temporarily down |
Default limits per API key:
| Limit | Value |
|---|---|
| Requests per minute | 60 RPM |
| Tokens per minute | ~500K TPM |
| Max context | Depends on model (see table above) |
Need higher limits? Contact us.
from langchain_openai import ChatOpenAI llm = ChatOpenAI( model="deepseek-chat", api_key="sk-YOUR_API_KEY", base_url="https://api.tunanapi.com/v1" ) response = llm.invoke("Explain quantum computing in one paragraph") print(response.content)
# Set environment variables export OPENAI_API_KEY="sk-YOUR_API_KEY" export OPENAI_BASE_URL="https://api.tunanapi.com/v1" # Use the CLI openai api chat_completions.create -m deepseek-chat -g user "Hello!"
# Check your remaining quota curl https://api.tunanapi.com/api/user/self \ -H "Authorization: Bearer sk-YOUR_API_KEY"