DeepSeek Configuration
This guide needs an API key
Create an account and generate one in about a minute, then use it wherever the steps below expect a key.
No card required to sign up · API usage requires a top-up
DeepSeek models are available through Code By AI's OpenAI-compatible Chat Completions endpoint. Point any OpenAI SDK or compatible client at the site base URL, use a Code By AI API key, and send an explicit DeepSeek model ID.
Models and prices
deepseek-v4.1-flashdeepseek-v4-pro
Neither model is a channel default, so send the exact ID in every request. See the DeepSeek pricing page for current input, cache-hit, and output rates. The off-peak (valley) rate applies around the clock with no peak surcharge.
Configure the environment variables
Both variables below are read by OpenAI-compatible clients. The key is created on the API Keys page.
macOS or Linux
Add these lines to ~/.zshrc (zsh) or ~/.bashrc (bash), then run source on the file:
1 export OPENAI_BASE_URL="https://www.codebyai.net/api/agent"2 export OPENAI_API_KEY="sk-proj-xxxx"
Windows
Set the same variables for your user account in Command Prompt:
1 setx OPENAI_BASE_URL "https://www.codebyai.net/api/agent"2 setx OPENAI_API_KEY "sk-proj-xxxx"
Open a new terminal after setx so the client inherits the values.
Send a Chat Completions request
The client must use OpenAI-compatible Chat Completions. Both /api/agent/v1/chat/completions and /api/agent/chat/completions are routed:
1 curl --fail-with-body "https://www.codebyai.net/api/agent/v1/chat/completions" \2 -H "Authorization: Bearer $OPENAI_API_KEY" \3 -H "content-type: application/json" \4 -d '{5 "model": "deepseek-v4.1-flash",6 "messages": [{ "role": "user", "content": "Hello" }]7 }'
Replace the model ID with deepseek-v4-pro to use the larger model. The Responses endpoint does not serve DeepSeek, and omitting model does not select a DeepSeek model.
Use an OpenAI SDK
The official SDK reads OPENAI_BASE_URL and OPENAI_API_KEY from the environment configured above. Pass the model ID on every call:
1 from openai import OpenAI2 3 client = OpenAI()4 response = client.chat.completions.create(5 model="deepseek-v4.1-flash",6 messages=[{"role": "user", "content": "Hello"}],7 )8 print(response.choices[0].message.content)
Troubleshooting
403withInvalid keymeans the key is invalid, revoked, or expired. CheckOPENAI_API_KEYand make sure theAuthorizationheader sends it as aBearertoken.400 Unknown modelmeans the ID is not in the catalog. Usedeepseek-v4.1-flashordeepseek-v4-proexactly.400on/v1/responsesis expected: DeepSeek is served only on Chat Completions.- Balance and per-model usage are listed in the dashboard; a request rejected before the model answers is not charged.
Get started
Four steps to your first request
- 01
Create a free account
Sign up with Google, GitHub or email and set a password. No card is required.
- 02
Generate an API key
Create a key in one click from the dashboard. It lets your CLI authenticate with Code By AI.
- 03
Top up your balance
Add credit before your first request; usage is charged per token from your balance.
- 04
Point your CLI at Code By AI
Export one base-URL variable, or add a model provider block to config.toml. The setup guides list the exact lines for each agent.
No card required to sign up · API usage requires a top-up