Headers allow you to pass request-specific values (like user IDs, authentication tokens, or organization metadata) to your Agent at runtime via HTTP headers. These values are validated, cached per conversation, and made available throughout your Agent system for:
Context Fetchers: Dynamic data retrieval based on request values
External Tools: Authentication and personalization for API calls
Agent Prompts: Personalized responses using context variables
Include context values as HTTP headers when calling your agent API. These headers are validated against your configured schema and cached for the conversation.
curl -N \ -X POST "http://localhost:3003/api/chat" \ -H "Authorization: Bearer $INKEEP_API_KEY" \ -H "user_id: u_123" \ -H "auth_token: t_abc" \ -H "org_name: Acme Corp" \ -H "Content-Type: application/json" \ -d '{ "messages": [ { "role": "user", "content": "What can you help me with?" } ], "conversationId": "conv-123" }'
Note
Header keys are normalized to lowercase. Define them as lowercase in your schema and reference them as lowercase in templates.
Header values can be used in your agent prompts and fetch definitions using JSONPath template syntax {{headers.field_name}}.
You can use the headers schema's toTemplate() method for type-safe templating with autocomplete and validation.
Reference context directly in agent prompts for personalization using the context config's template method:
// Create context config with both headers and fetchersconst userContext = contextConfig({ headers: requestHeaders, contextVariables: { userName: userDataFetcher, },});const assistantAgent = subAgent({ prompt: `You are an assistant for ${userContext.toTemplate('userName')} from ${requestHeaders.toTemplate('org_name')}. User context: - ID: ${requestHeaders.toTemplate('user_id')} - Organization: ${requestHeaders.toTemplate('org_name')} Provide help tailored to their organization's needs.`});
When using the Inkeep chat components, the following headers are automatically sent with each request:
Header
Description
Example Value
x-inkeep-client-timestamp
The client's current timestamp in ISO 8601 format
2025-01-30T18:15:00.000Z
x-inkeep-client-timezone
The client's timezone identifier
America/New_York
These headers are useful for providing time-aware responses:
const timeAwareHeaders = headers({ schema: z.object({ 'x-inkeep-client-timestamp': z.string().optional(), 'x-inkeep-client-timezone': z.string().optional(), }),});const timeAwareContext = contextConfig({ headers: timeAwareHeaders,});const assistantAgent = subAgent({ prompt: `You are a helpful assistant. The user's current time is: ${timeAwareHeaders.toTemplate('x-inkeep-client-timestamp')} The user's timezone is: ${timeAwareHeaders.toTemplate('x-inkeep-client-timezone')} Use this information to provide time-relevant responses when appropriate.`});