Links

Traces

Having end-to-end visibility of your requests is crucial. Portkey supports request tracing to help you monitor your applications throughout the lifecycle of a request.
To enable tracing, you can pass a trace-id in the header of any request made via Portkey. This trace ID will be associated with the journey of the request, from initiation to completion, providing insights into the entire process.

How to Enable Request Tracing

To enable tracing, include the x-portkey-trace-id in your request header.
{
"x-portkey-trace-id": "<YOUR TRACE ID>"
}
or pass it as request config parameter when using the Portkey or OpenAI SDKs.
NodeJS
Python
OpenAI NodeJS
OpenAI Python
const requestOptions = {traceID: "YOUR TRACE ID"}
const chatCompletion = await portkey.chat.completions.create({
messages: [{ role: 'user', content: 'Say this is a test' }],
model: 'gpt-3.5-turbo',
}, requestOptions);
console.log(chatCompletion.choices);
completion = portkey.with_options(
trace_id = "TRACE_ID"
).chat.completions.create(
messages = [{ "role": 'user', "content": 'Say this is a test' }],
model = 'gpt-3.5-turbo'
)
const reqHeaders = {headers: createHeaders({"traceID": "TRACE ID"})}
const chatCompletion = await openai.chat.completions.create({
messages: [{ role: 'user', content: 'Say this is a test' }],
model: 'gpt-3.5-turbo',
}, reqHeaders);
req_headers = createHeaders(trace_id="TRACE ID")
chat_complete = client.with_options(headers=req_headers).chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": "Say this is a test"}],
)

Tracing and User Feedback

Trace IDs can also be used to link user feedback to specific generations. This can be used in a system where users provide feedback, like a thumbs up or thumbs down, or something more complex via our feedback APIs. This feedback can be linked to traces which can span over a single generation or multiple ones.
You can view all the requests with a common trace-id easily on the logs page.
Last modified 1mo ago