One key, two models.
Qwen 3.8 27B and DeepSeek V4.1 Flash through OpenAI-compatible Chat Completions or Responses.
Make your first call
- Export your keyKeep it in a server-side environment variable.
- GET /modelsRead the current model IDs and capabilities.
- Send an exact model IDEvery generation request requires the model field.
$ export BHARATCODE_API_KEY=bc_live_your_key_here $ curl https://bharatcode.ai/api/model/v1/models -H "Authorization: Bearer $BHARATCODE_API_KEY"
Models available now
qwen-3.8-27b/responses · /chat/completionsStudents (10M tokens a day), Lite and Prodeepseek-v4.1-flash/responses · /chat/completionsProCopy a working request
Every request needs the model field. Examples use a Bash-compatible shell.
POSTCreate a response/responses
Send input as text or a message array, with optional instructions. Use store:false. Read text and function calls from the output array.
$ curl https://bharatcode.ai/api/model/v1/responses -H "Authorization: Bearer $BHARATCODE_API_KEY" -H "Content-Type: application/json" -d '{"model":"qwen-3.8-27b","input":"Say hello from BharatCode","store":false}'
POSTStream a response/responses
Set stream:true for server-sent events. Text arrives in response.output_text.delta; finish on response.completed or response.incomplete. Handle response.failed as an error, not a successful response. Queue keepalive comments are not model output.
$ curl -N https://bharatcode.ai/api/model/v1/responses -H "Authorization: Bearer $BHARATCODE_API_KEY" -H "Content-Type: application/json" -d '{"model":"qwen-3.8-27b","input":"Explain a binary search in three steps","store":false,"stream":true}'
POSTCall your own tools/responses
Define function tools using name and parameters. Your application validates arguments and executes the function; BharatCode does not run it. For the next request, include the original input, the response.output items, and a function_call_output item with the matching call_id and a string output. Keep store:false and resend any tool definitions you still need.
$ curl https://bharatcode.ai/api/model/v1/responses -H "Authorization: Bearer $BHARATCODE_API_KEY" -H "Content-Type: application/json" -d '{"model":"qwen-3.8-27b","input":"What is the weather in Delhi?","store":false,"tools":[{"type":"function","name":"get_weather","description":"Look up current weather for a city","parameters":{"type":"object","properties":{"city":{"type":"string"}},"required":["city"],"additionalProperties":false},"strict":true}],"tool_choice":{"type":"function","name":"get_weather"}}'
POSTGenerate code and call tools/chat/completions
Send OpenAI-compatible messages to Qwen 3.8 27B or DeepSeek V4.1 Flash. The model field is required.
$ curl https://bharatcode.ai/api/model/v1/chat/completions -H "Authorization: Bearer $BHARATCODE_API_KEY" -H "Content-Type: application/json" -d '{"model":"qwen-3.8-27b","messages":[{"role":"user","content":"Say hello from BharatCode"}]}'
Use the OpenAI SDK
Point the OpenAI SDK at the BharatCode base URL. Keep your key on the server.
import OpenAI from 'openai' const client = new OpenAI({ apiKey: process.env.BHARATCODE_API_KEY, baseURL: 'https://bharatcode.ai/api/model/v1', }) const response = await client.responses.create({ model: 'qwen-3.8-27b', input: 'Build a study planner schema', store: false, }) console.log(response.output_text)
Responses support
- Supported: text and image input, streaming, your own function tools, and structured output through
text.format. Send the conversation history with each request. - Not supported:
store:true,previous_response_id, hosted tools, background jobs, and audio, video or file input. These return400.
When it's busy
A 503 means the model is busy. Wait a few seconds and retry. A stream that has already started ends with response.failed instead.