Curl Examples¶
This guide provides curl examples for interacting with Adastra LLMGW directly via HTTP requests.
Prerequisites¶
Set your environment variables:
export LLMGW_API_ENDPOINT="https://<llmgw-deployment-url>"
export LLMGW_API_KEY="<YOUR_LLMGW_API_KEY>"
Azure OpenAI Endpoint¶
Basic Chat Completion¶
curl -X POST "$LLMGW_API_ENDPOINT/azure-open-ai/deployments/gpt-4.1/chat/completions?api-version=2025-01-01-preview" \
-H "Content-Type: application/json" \
-H "api-key: $LLMGW_API_KEY" \
-H "llmgw-user: your-user" \
-d '{
"messages": [
{
"role": "user",
"content": "What's the weather like?"
}
]
}'
Streaming Chat Completion¶
curl -X POST "$LLMGW_API_ENDPOINT/azure-open-ai/deployments/gpt-4.1/chat/completions?api-version=2025-01-01-preview" \
-H "Content-Type: application/json" \
-H "api-key: $LLMGW_API_KEY" \
-H "llmgw-user: your-user" \
-d '{
"messages": [
{
"role": "user",
"content": "Tell me a story"
}
],
"stream": true
}'
View Response Headers¶
Add the -i flag to see response headers including LLMGW metadata:
curl -i -X POST "$LLMGW_API_ENDPOINT/azure-open-ai/deployments/gpt-4.1/chat/completions?api-version=2025-01-01-preview" \
-H "Content-Type: application/json" \
-H "api-key: $LLMGW_API_KEY" \
-H "llmgw-user: your-user" \
-d '{
"messages": [
{
"role": "user",
"content": "What's the weather like?"
}
]
}'
Response headers will include:
x-llmgw-cost: 0.00004
x-llmgw-request-id: 3cb26481-d869-4923-8093-3feb92f8d9fc
x-llmgw-model-id: azure-us-gpt35
x-llmgw-attempts: 1
For full details and what headers are included, see Response Headers.
OpenAI Endpoint¶
Basic Chat Completion¶
curl -X POST "$LLMGW_API_ENDPOINT/openai/v1/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $LLMGW_API_KEY" \
-H "llmgw-user: your-user" \
-d '{
"model": gpt-4.1",
"messages": [
{
"role": "user",
"content": What's the weather like?"
}
]
}'
Create Embeddings¶
curl -X POST "$LLMGW_API_ENDPOINT/openai/v1/embeddings" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $LLMGW_API_KEY" \
-H "llmgw-user: your-user" \
-d '{
"model": text-embedding-3-large",
"input": "Text to embed"
}'
List Available Models¶
Call AWS Bedrock Models via OpenAI Endpoint¶
curl -X POST "$LLMGW_API_ENDPOINT/openai/v1/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $LLMGW_API_KEY" \
-H "llmgw-user: your-user" \
-d '{
"model": anthropic.claude-sonnet-4-5-20250929-v1:0",
"messages": [
{
"role": "user",
"content": "Tell me a story"
}
]
}'
AWS Bedrock Endpoint¶
Invoke Claude Model¶
curl -X POST "$LLMGW_API_ENDPOINT/aws-bedrock/model/anthropic.claude-sonnet-4-5-20250929-v1:0/invoke" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $LLMGW_API_KEY" \
-H "llmgw-user: your-user" \
-d '{
"max_tokens": 150,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What's the weather like?"
}
]
}
]
}'
View Response Headers¶
curl -i -X POST "$LLMGW_API_ENDPOINT/aws-bedrock/model/anthropic.claude-sonnet-4-5-20250929-v1:0/invoke" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $LLMGW_API_KEY" \
-H "llmgw-user: your-user" \
-d '{
"max_tokens": 150,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What's the weather like?"
}
]
}
]
}'
Common Headers¶
All LLMGW endpoints support these custom headers:
| Header | Description | Required |
|---|---|---|
llmgw-user |
User identifier for tracking and billing | Check with admin |
Response Headers¶
All responses include LLMGW metadata headers:
x-llmgw-request-id- Unique request identifier for debuggingx-llmgw-model-id- Actual model used (may differ due to load balancing)x-llmgw-cost- Request cost in USDx-llmgw-attempts- Number of retry attemptsx-llmgw-remaining-limits- Remaining usage limits
See Response Headers for more details.
Tips¶
- Use
-iflag to view response headers - Use
-vflag for verbose output including request headers - Use
-sflag for silent mode (no progress meter) - Set environment variables to avoid repeating credentials
- Add
| jqto prettify JSON responses (requires jq to be installed)