Response Headers
Adastra LLMGW includes custom response headers that provide valuable metadata about each request. All LLMGW-specific headers are prefixed with x-llmgw- to distinguish them from standard HTTP headers.
Available Headers
x-llmgw-request-id
Type: String (UUID)
Description: A unique identifier for the request that can be used for tracking and debugging purposes.
Example: 3cb26481-d869-4923-8093-3feb92f8d9fc
x-llmgw-model-id
Type: String
Description: The actual model ID that was used to process the request. This may differ from the requested model if load balancing or failover occurred.
Example: azure-us-gpt35
x-llmgw-attempts
Type: Integer (as string)
Description: The number of attempts made to get a successful response. This is useful for understanding retry behavior and service reliability.
Example: 2
x-llmgw-cost
Type: Decimal (as string)
Description: The cost of the request in cents. This helps track spending and usage costs.
Example: 4e-05 (0.00004 cents)
x-llmgw-remaining-limits
Type: String (formatted)
Description: Information about remaining usage limits for the requesting entity. The format is {entity_name}/{limit_id}/{remaining_amount}. Multiple limits may be returned as separate headers.
Example: user/daily-tokens/9500
Accessing Headers
With OpenAI Client
To access response headers when using the OpenAI client, use the with_raw_response method:
With Langchain
When using Langchain, ensure you set include_response_headers=True in your model configuration:
Example Response Headers
A typical response might include headers like this:
Use Cases
These headers are particularly useful for:
- Cost Tracking: Monitor spending using the
x-llmgw-costheader - Debugging: Use
x-llmgw-request-idto trace specific requests in logs - Load Balancing Analysis: Check
x-llmgw-model-idto see which model actually processed your request - Reliability Monitoring: Monitor
x-llmgw-attemptsto understand retry patterns - Usage Management: Track remaining limits with
x-llmgw-remaining-limits
Important Notes
- Headers are returned for both successful and failed requests (when possible)
- The
x-llmgw-remaining-limitsheader may appear multiple times if multiple limits apply - All cost values are in cents (USD)
- Request IDs are unique across all requests and can be used for support inquiries