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

# Portkey

> Read LLM gateway analytics from Portkey - cost, request, and token usage over time, per-user summaries, virtual keys, and log exports

## At a glance

* **Availability**: Experimental ([how to enable](/cloud/integrations)).
* **Auth**: API key.
* **Connection**: The key from `PORTKEY_API_KEY` is sent as the `x-portkey-api-key` header.
* **Docs**: [https://portkey.ai/docs/api-reference/admin-api/introduction](https://portkey.ai/docs/api-reference/admin-api/introduction)

## Credentials

Set these per environment. See [Connect an integration](/cloud/integrations).

| Variable          | Required | Description                                                                                                                                                                          |
| ----------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `PORTKEY_API_KEY` | Yes      | Portkey API key - analytics endpoints require an Admin API key (organization-wide) rather than a workspace key [Docs](https://portkey.ai/docs/api-reference/admin-api/introduction). |

## Setup

1. **Create a Portkey account**: Go to [https://app.portkey.ai](https://app.portkey.ai) and sign up - the free developer plan is enough to test the gateway and analytics.
2. **Create an Admin API key**: In the Portkey dashboard, open API Keys ([https://app.portkey.ai/api-keys](https://app.portkey.ai/api-keys)) and create an Admin API key. Admin keys grant organization-wide access; workspace keys cannot call the analytics endpoints. You need the Organization Owner or Admin role.
3. **Store the key**: Add it to your .env file as PORTKEY\_API\_KEY=...
4. **Find your workspace slug**: The workspace slug is visible in the Portkey dashboard URL and workspace settings; analytics tools require it as the workspace\_slug parameter.
5. **Verify access**: Run Get Cost Analytics with a recent date range. A 401 means the key is invalid; a 403 usually means you used a workspace key instead of an Admin key.

* Analytics only covers traffic routed through the Portkey gateway - direct provider calls won't appear
* Time range parameters (time\_of\_generation\_min/max) are required on all analytics endpoints and must be ISO8601 timestamps
* The virtual keys API is deprecated in favor of the newer Providers API, but existing virtual keys still work and remain listable

Provider API reference: [https://portkey.ai/docs/api-reference/admin-api/introduction](https://portkey.ai/docs/api-reference/admin-api/introduction)

## Tools

| Tool                        | Access | Description                                                                                                         |
| --------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------- |
| Get Cost Analytics          | Read   | Get time-series LLM spend data for a workspace over a date range, optionally filtered by model, status, or metadata |
| Get Request Analytics       | Read   | Get time-series request volume data for a workspace over a date range to spot traffic spikes and error trends       |
| Get Token Analytics         | Read   | Get time-series token consumption data for a workspace over a date range                                            |
| Get User Analytics Summary  | Read   | Get per-user grouped analytics (request counts and cost) for a workspace over a date range                          |
| Get Model Analytics Summary | Read   | Get per-model grouped analytics (request counts) for a workspace over a date range - spend and traffic by model     |
| List Workspaces             | Read   | List the organization's workspaces with their IDs and slugs - feeds the workspace\_slug every analytics tool needs  |
| List Virtual Keys           | Read   | List virtual keys (managed provider credentials) with their status, usage limits, and expiry                        |
| List Log Exports            | Read   | List log export tasks for a workspace (Portkey exposes gateway logs via exports rather than a direct list endpoint) |

## Example prompts

* Pull my Portkey cost analytics for the last 30 days and summarize spend trends by model.
* Show me Portkey request and token usage for the last week and flag any unusual spikes or error rates.
* List my Portkey virtual keys and flag any that are exhausted or close to expiry.
