Top up your wallet, then open the setup wizard to create an API key. Store the key in an environment variable; you can view it again on the API keys page.
Call GET /v1/models to get the models you can use instead of hard-coding a model ID.
Key points
- Keep the API key in an environment variable, never in source code.
- Use the base URL shown in the setup wizard.
- Call GET /v1/models and choose a model ID.
- Use stream=false for JSON, or stream=true to receive the answer in parts until [DONE].
- Keep the x-routing-request-id header (your request ID) to include with support requests.
Example request
POST /v1/chat/completions
curl --request POST 'https://api.xpncore.com/v1/chat/completions' \
--max-time 35 \
--header "Authorization: Bearer $API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "MODEL_ID_FROM_GET_V1_MODELS",
"messages": [
{
"role": "user",
"content": "Hello from the gateway"
}
],
"temperature": 0.7,
"max_tokens": 512,
"stream": false
}'