This example uses the chat-completions endpoint with a placeholder model name. Create an API key in your XenAI dashboard, set it in your local environment, and keep the key out of source control.
curl https://api.xenai.app/v1/chat/completions \
-H "Authorization: Bearer $XENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "your-model",
"messages": [
{ "role": "user", "content": "Hello from XenAI" }
]
}'
Choose a model and inspect the response
Replace the placeholder with a model identifier available to your account. The request follows the familiar chat-completions format, and the response includes the generated message and usage details. Check the API documentation for current model names and request options.
Once the request works locally, move the call into your server-side application and read the API key from a secure environment variable. Avoid putting secrets in browser code or committing them to a repository.