Base URL and Authentication
Start every request by pointing your client to the correct base URL. Use the key you received during signup to pass in the Authorization header. This header authenticates your account and tracks your prepaid credit usage.
Our infrastructure is built for developers who want direct access without intermediary routing fees. You get consistent performance because we run our own servers.
First Request
Send your first message to verify connectivity and model response. Use the standard chat completions endpoint with your system prompt and user query. This confirms your key works and shows you the raw JSON response.
- Set the
modelfield touncensored. - Include a simple user message to test latency.
- Check the
usageobject for token counts.
Python SDK
Integrate quickly using the official Python library. Install the package and initialize the client with your base URL and key. This approach handles serialization and retries automatically.
Define your conversation history as a list of dictionaries. Pass these directly to the chat endpoint. The library returns a structured response object you can parse for the assistant's text.
Node SDK
Build server-side logic with the Node.js client. Import the library and configure the API key and base URL. This setup works well for backend services that process user inputs asynchronously.
Call the completion method with your messages. The response includes the generated text and usage statistics. Handle errors gracefully to avoid crashing your application during high load.
Streaming Responses
Receive tokens in real-time for a smoother user experience. Enable streaming by setting the appropriate flag in your request. The server sends data chunks as they are generated.
Accumulate these chunks on the client side to display text progressively. This reduces perceived latency significantly. Monitor the final chunk for total token usage and billing data.
Limits, Errors and Context
Respect the rate limits to avoid interruptions. You are allowed 300 requests per minute and 8 concurrent connections per key. If you exceed this, you will receive a 429 error.
A 401 error means your API key is invalid. A 402 error indicates insufficient prepaid credit. Your context window is 100,000 tokens total. Keep your prompt and response within this limit to ensure reliable performance.
cURL
curl https://api.deepseekapiaccess.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Calculate the total latency for three sequential API calls."}]
}'Python
from openai import OpenAI
client = OpenAI(base_url="https://api.deepseekapiaccess.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)Node.js
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.deepseekapiaccess.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);Streaming
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)