Add metadata to your API requests using the x-glama-metadata HTTP header. Attached labels help track and filter requests in logs dashboard.
The x-glama-metadata header uses metadata in the form of JSON:
{
"labels": [
{ "key": "foo", "value": "bar" }
]
}-, _, or ..string, number or a boolean.Malformed metadata will result in the metadata being ignored. If you are not seeing the metadata in your logs, this is likely the cause.
curl -X POST https://glama.ai/gateway/openai/v1/chat/completions \
-H 'Content-Type: application/json' \
-H 'X-Glama-Metadata: { "labels": [ { "key": "foo", "value": "bar" } ] }' \
-d '{
"model": "gpt-4",
"messages": [
{"role": "user", "content": "Hello, World!"}
]
}'import { OpenAI } from 'openai'
const openai = new OpenAI({
baseURL: 'https://glama.ai/api/gateway/openai/v1',
apiKey: GLAMA_API_KEY,
});
await openai.chat.completions.create(
{
messages: [
{ role: 'user', content: 'Hello!' }
],
model: 'anthropic/claude-2',
},
headers: {
"x-glama-metadata": JSON.stringify({
labels: [
{
key: 'foo',
value: 'bar'
}
]
}),
},
);Filter logs at /logs using labels.
environment=productionuser_id=12345environment=staging and priority=high