Authentication and Base URL Setup
Your API key authenticates every request to our servers. Simply sign up with Google or an email address and copy the key from your dashboard. Paste it into your environment variable as DEEPSEEK_API_KEY and point your client to https://api.keyapideepseek.com/v1. This base URL works with any standard OpenAI-compatible library.
curl https://api.keyapideepseek.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Check the system health and confirm uptime status"}]
}'You can verify your setup by listing available models. The response confirms your key is valid and active. This step ensures your integration points to the correct uncensored endpoint before you send prompts.
Chat Completions Endpoint
The POST /v1/chat/completions endpoint accepts your prompt and returns the model response. You send a JSON body containing messages, your system instructions, and parameters like temperature. The model id is always uncensored. This single model handles all your text generation needs without routing complexity.
from openai import OpenAI
client = OpenAI(base_url="https://api.keyapideepseek.com/v1", api_key="YOUR_KEY")
resp = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Summarise this thread without softening it."}],
)
print(resp.choices[0].message.content)The Python SDK handles the HTTP requests automatically. You pass your key and the base URL to the client constructor. The rest of the code mirrors standard OpenAI patterns. This ensures you can switch vendors later without rewriting your entire application logic.
Streaming Responses and Token Usage
Enable streaming by setting stream: true in your request. The API returns a Server-Sent Events (SSE) stream of chunks. Each chunk contains partial text and usage statistics. The final chunk includes the total token counts for the request.
stream = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Tell the story in second person."}],
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)Streaming reduces perceived latency for users. You can display tokens as they arrive. This is crucial for long-form generation or interactive chat interfaces. Monitor the token usage in the final chunk to track your prepaid credit consumption accurately.
JSON Mode and Function Calling
Enforce structured output by setting response_format to {"type": "json_object"}. The model will return valid JSON instead of free-form text. This is ideal for API integrations or data extraction tasks. You can also define function definitions in your prompt for tool use.
The model supports tool_choice parameters. You can force specific functions or let the model decide. This flexibility allows you to build complex agents. Ensure your function schemas are strictly typed to avoid parsing errors in your client code.
Rate Limits and Concurrency
Each API key is limited to 300 requests per minute. You can have up to 8 concurrent requests active simultaneously. The maximum request body size is 8 MB. These limits prevent abuse and ensure stable performance for all users. Exceeding these limits returns a 429 error.
Implement exponential backoff in your client code. Retry failed requests after a short delay. This handles transient network issues gracefully. Your prepaid credit is charged only for successful completions, not for rate-limited retries.
Error Handling and Refusals
A 401 error means your key is invalid or expired. A 402 error indicates insufficient prepaid credit. A 429 error signals you have hit the rate limit. The model refuses requests containing sexual content involving minors. All other lawful adult content is allowed.
Check the error response body for detailed messages. Log these errors to debug integration issues. Your credit is not consumed for failed requests. This transparent billing model helps you predict costs accurately without hidden fees.
Node.js
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.keyapideepseek.com/v1", apiKey: process.env.API_KEY });
const resp = await client.chat.completions.create({
model: "uncensored",
messages: [{ role: "user", content: "Draft a villain monologue for my game." }],
});
console.log(resp.choices[0].message.content);