Skip to content
THE-CODE API

Your first request

Connect an application to the models available through your The-Code account.

1. Create an account and a key

Get started opens our hosted account flow. Already have an account? Sign in, then open Dashboard → API keys.

Create a named key, copy it when it is displayed, and store it in your application's server environment as THE_CODE_API_KEY. Keep it out of browser code, source control, and chat messages. Keys belong to your account; your enabled models and wallet determine what they can use.

2. Set the base URL

For OpenAI-compatible SDKs:

text
https://api.thecodeapi.com/v1

For raw HTTP calls, use the API origin https://api.thecodeapi.com and the full endpoint path, such as /v1/chat/completions. Add /v1 only once.

3. Discover your models

bash
curl https://api.thecodeapi.com/v1/models \
  -H "Authorization: Bearer $THE_CODE_API_KEY"

Choose an exact returned id with the chat capability and store it as THE_CODE_MODEL. The response also describes model limits and supported request parameters. If no suitable model appears, check your enabled models in the dashboard or contact support. Never assume a model is available because it appears in an upstream provider's catalog.

4. Make a request

Check your wallet balance first. Inference uses credits; there is no implied free request. Install the OpenAI SDK for your language (pip install openai or npm install openai) and use the examples below. Set an output limit appropriate for the selected model and task.

The non-streaming chat response contains choices, with generated text typically in choices[0].message.content, and usage information. Tool-calling responses can contain tool calls instead of text. See streaming and errors before putting an integration into production.

Need help? Support@the-code.org.

curl request
curl https://api.thecodeapi.com/v1/chat/completions \
  -H "Authorization: Bearer $THE_CODE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"REPLACE_WITH_A_CHAT_MODEL_ID","messages":[{"role":"user","content":"Say hello in one sentence."}],"max_tokens":256}'