Integrate HTTP with Divyam
Send a JSON request directly to Divyam’s Chat Completions endpoint. Use this guide for curl or an application with its own HTTP client.
Prepare your account
Follow the console guide to sign in and create an API key. Copy the base URL from Getting Started and an available ID from Models & Pricing. You need curl and Bash for the terminal example below.
Set your connection
Substitute your copied base URL and model if they differ.
export DIVYAM_BASE_URL='https://api.demo.divyam.ai/v1'
export DIVYAM_MODEL='divyam-as/gpt-5.6-sol'
read -rsp 'Divyam API key: ' DIVYAM_API_KEY
printf '\n'
export DIVYAM_API_KEY
Paste your key at the prompt and press Enter. It stays hidden while you enter it. These variables apply to commands started from this terminal.
Send a request
Run this from the same Bash terminal:
curl --silent --show-error --include \
"${DIVYAM_BASE_URL%/}/chat/completions" \
-H "Authorization: Bearer ${DIVYAM_API_KEY}" \
-H 'Content-Type: application/json' \
--data-binary @- <<JSON
{
"model": "${DIVYAM_MODEL}",
"messages": [{"role": "user", "content": "Say hello in one sentence."}]
}
JSON
Expect HTTP 200 and a JSON response containing choices[0].message.content.
The command shows response headers so you can inspect the HTTP status.
Curl can finish successfully even when the server returns an error status; check the response itself.
Record the request time and find it in Divyam Logs.
Configure your HTTP client
| Field | Value |
|---|---|
| Method | POST |
| URL | Your Divyam base URL followed by /chat/completions |
| Authorization header | Bearer followed by your complete Divyam API key |
| Content-Type header | application/json |
| JSON body | Your chosen model and application’s messages |
Build the JSON body with your HTTP client’s JSON serializer. Do not construct application messages through shell substitution. Keep the credential in your backend or trusted connection settings.
A direct HTTP client needs the complete completion URL.
An OpenAI SDK’s base-URL setting needs the base URL alone; the SDK appends /chat/completions.
Test your application
Replace the example messages with your application’s actual request body. Preserve conversation history and tool-result handling. If your application uses streaming, test its event-stream handling through the normal application workflow.
Run the application workflow tests and review usage for the requested catalog model. Use Troubleshooting for non-2xx responses. Use the rotation guide when replacing credentials.