> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zespan.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Portkey (Gateway)

> Send Portkey's OpenTelemetry traces to Zespan with its experimental OTel export, no Zespan SDK required.

> [!NOTE]
>
> Available via: **Portkey's experimental OpenTelemetry export** on Enterprise and self-hosted Portkey. This is not a Zespan SDK wrapper, see [Send traces from any OTel-instrumented app](https://docs.zespan.com/sdk/otel-integration.md#send-traces-from-any-otel-instrumented-app-no-zespan-sdk) for how the endpoint works.

[Portkey](https://portkey.ai/docs) can export a trace for every request it handles. Point that export at Zespan and every call that passes through the gateway is stored with its model, provider and token counts, without changing the apps that call it.

## Setup

**1. Turn on Portkey's OpenTelemetry export**

Portkey's export is experimental and is switched on with environment variables of your Portkey deployment (Enterprise or self-hosted): `EXPERIMENTAL_GEN_AI_OTEL_TRACES_ENABLED=true`, the endpoint in `EXPERIMENTAL_GEN_AI_OTEL_EXPORTER_OTLP_ENDPOINT` and headers in `EXPERIMENTAL_GEN_AI_OTEL_EXPORTER_OTLP_HEADERS` (comma-separated `key=value`). These are the names in Portkey's documentation; check them for your version.

**2. Set the destination**

Use `https://api.zespan.com` as the base URL: Portkey appends `/v1/traces` itself. Send your project key in a header, `x-api-key=zsp_...` (or `Authorization=Bearer zsp_...`). Portkey sends JSON, which Zespan accepts.

**3. Verify**

Send one request through Portkey, then open **Settings → Instrumentation → Gateway and OTLP data** and press **Refresh**. The source should appear with tokens and span kind near 100%. See [Instrumentation](https://docs.zespan.com/dashboard/instrumentation.md#gateway-and-otlp-data).

## What gets captured

| Field | Read from | Notes |
| - | - | - |
| Model, provider, token counts | Current GenAI attribute names (Portkey reports GenAI semantic conventions 1.40) | Cache read and cache creation tokens: `gen_ai.usage.cache_read.input_tokens`, `gen_ai.usage.cache_creation.input_tokens` |
| Cost | Zespan's own price table | Portkey puts no cost on its spans |
| Prompt and answer text | `gen_ai.input.messages`, `gen_ai.output.messages` | Portkey documents no switch to turn this off, so check your project's prompt storage setting first |
| End user | Not read | Portkey's user attribute (`portkey.user.id`) is a user id or an API key id, not your end user |
| Trace link to the SDK | Not documented | Portkey uses its own trace id when it is 32 hex characters |

> [!NOTE]
>
> Attribute names come from Portkey's published documentation and can change between versions. Use the **Gateway and OTLP data** card to see what actually arrives. Portkey documents the export as experimental.

> [!NOTE]
>
> Gateway identity metadata (for example an API key id or workspace label) is not stored, and prompt and answer text follows your project's capture and redaction settings. See [AI gateways](https://docs.zespan.com/sdk/otel-integration.md#ai-gateways) and [Security](https://docs.zespan.com/platform/security.md).

## Using the SDK too

If your app also uses the Zespan SDK for the same call, Zespan can count its tokens and cost once when merging is on (see the linked section). Portkey documents the provider's response id on its span (`gen_ai.response.id`), so the two rows can be matched by that id without an SDK setting. Portkey does not document an inbound `traceparent`, so matching relies on the response id. See [Using the SDK too](https://docs.zespan.com/sdk/otel-integration.md#using-the-sdk-too).

## Next steps

* [OTel integration](https://docs.zespan.com/sdk/otel-integration.md), the endpoint, limits and attributes Zespan reads
* [Instrumentation](https://docs.zespan.com/dashboard/instrumentation.md#gateway-and-otlp-data), check what arrived
* [LiteLLM Proxy](https://docs.zespan.com/sdk/integrations/litellm-proxy.md), [Kong AI Gateway](https://docs.zespan.com/sdk/integrations/kong-ai-gateway.md), [Vercel AI Gateway](https://docs.zespan.com/sdk/integrations/vercel-ai-gateway.md), other gateways


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.