Docs/Integrations/Portkey

Portkey Connector

If your agents call models through Portkey, the Portkey connector brings that traffic into ANTS Platform and puts ANTS controls on it, with no change to agent code. It connects to Portkey in three ways:

ConnectionWhat ANTS doesWhat it enables
Log ingestionIngests Portkey's OpenTelemetry log exportAgents using Portkey are discovered with their models, tools and requesting users, and their traffic appears in Tracing, the AI Agent Center and detection
Admin APICalls Portkey's admin API with an admin key you provideExpiry, disable and enable on Portkey API keys
Guardrail webhookActs as a Portkey "bring your own guardrail" webhookRequests and responses are checked inline with the agent's guardrail policy

You can use the three connections together or set up only the ones you need.

ℹ

Portkey's OpenTelemetry log export is available in its Enterprise and self-hosted editions and is marked experimental by Portkey. Without it, the admin API and guardrail webhook still work, but agents are not discovered from Portkey logs. ANTS sees only traffic that goes through Portkey, so route all agent traffic through it for full coverage.

Prerequisites

  • A Portkey deployment and its control-plane URL, the base URL of Portkey's admin API. For Portkey's cloud this is https://api.portkey.ai/v1. On a self-hosted Portkey it can differ from the gateway URL your agents call.
  • A Portkey admin API key that can read and update API keys.
  • In ANTS Platform, the Owner role or a custom role with AI Studio Connectors at Read & Write (under Integrations & service accounts in the role builder).
  • For the guardrail webhook, a Real-time Enforcement policy in AI Guardrails for the agents you want to check. The detection services are enabled per deployment.

Connect Portkey

Add the connector

Go to Project Settings > Integrations > Portkey and enter:

FieldNotes
Portkey URLThe control-plane URL. It must use https and resolve to a public address. A self-hosted Portkey on a private network must be allow-listed by your ANTS Platform administrator (PORTKEY_ALLOWED_PRIVATE_HOSTS).
Admin API keyEncrypted at rest and never shown again

Saving checks the admin key by listing your Portkey API keys. The page then shows a Webhook secret once, and the ANTS endpoints for the next two steps. Changing the Portkey URL requires entering the admin key again.

Send Portkey logs to ANTS

On an Enterprise or self-hosted Portkey, turn on the OpenTelemetry trace export and point it at your ANTS OTLP endpoint:

bash
EXPERIMENTAL_GEN_AI_OTEL_TRACES_ENABLED=true EXPERIMENTAL_GEN_AI_OTEL_EXPORTER_OTLP_ENDPOINT=https://<your-ants-host>/api/public/otel EXPERIMENTAL_GEN_AI_OTEL_EXPORTER_OTLP_HEADERS=Authorization=Basic <base64 of public-key:secret-key>

Use a project key pair from the project you connected. See OpenTelemetry for building the header.

Set agent_name on each agent's Portkey key

In Portkey, give each agent its own API key and set agent_name in that key's default metadata. ANTS uses it to recognise the agent in logs and in the guardrail webhook, and to link the key to the agent. Without it, the webhook cannot tell which agent a request belongs to.

Add ANTS as a Portkey guardrail

In Portkey, create a "bring your own guardrail" webhook check:

  • URL: https://<your-ants-host>/api/public/v1/guardrails/portkey
  • Header: Authorization: Bearer <webhook secret>
  • Timeout: 3000 ms

Attach it to your Portkey configs as a check before the request and after the response, and set the check to deny the request when it fails. If the check is not set to deny, Portkey records the failure but still sends the request.

Log ingestion and agent discovery

Portkey traces are recognised by their service.name of portkey. Each request becomes a trace in the project with the model, token usage, cost, latency, the requesting user and one span per tool call.

  • Agent. ANTS uses the agent_name from the request's Portkey metadata when the export includes it, then the agent_name in the key's default metadata, then the key's name. Agent names are stored in lowercase.
  • User. The requesting user comes from Portkey's _user metadata when the export includes it.
  • Tools. Tool calls in the model's responses are recorded under their raw names, and appear in AI TrailMaps.

Portkey traces are covered by Scheduled Detection, drift detection and cost reporting like any other trace.

ℹ

Portkey's export documentation does not list request metadata among its attributes. If your Portkey does not export it, agents are identified from each key's default metadata or name, which is another reason to set agent_name on every agent's key.

Portkey keys in ANTS

With the admin API key in place, Project Settings > Integrations > Portkey lists your Portkey API keys and the agents linked to each. ANTS refreshes the list about every 15 minutes.

  • Linked agents come from the key's default metadata agent_name or the key's name. Only linked agents control the key.
  • Seen only agents sent their own agent_name in request metadata while using the key. They are shown for information and never control the key.

Expiry

Set an expiry on any Portkey key, from 1 hour to 365 days. When it passes, ANTS disables the key in Portkey within about a minute by setting the key's own expiry to that moment. If Portkey cannot be reached, ANTS retries with increasing delays.

Disable and enable

You can disable a key from the list at any time. Enable restores the expiry the key had in Portkey before ANTS disabled it, needs step-up verification, and is refused once the key's ANTS expiry has passed. While an enable is being confirmed, the key shows Enabling.

If someone re-enables an ANTS-disabled key directly in Portkey, ANTS disables it again at the next refresh.

Keys disabled by an automatic suspension are enabled again when the agent is resumed with Resume agent, unless their ANTS expiry has passed in the meantime.

Audit

Disabling and enabling keys (by a person or automatically), failed disables, expiry changes and automatic re-disables are written to the audit log.

Guardrail webhook

Portkey calls ANTS before each request is sent to the model and after each response. ANTS identifies the agent from the agent_name in the request's metadata, which Portkey fills from the request or from the key's default metadata, and checks the content with that agent's AI Guardrails Real-time Enforcement policy.

Policy actionVerdict returned to Portkey
Audit OnlyPass. Violations, including tool calls that break the agent's tool permissions, are recorded.
BlockFail
RedactPass with the masked content, which Portkey uses in place of the last message or the response. The check still fails for Ethics & Bias violations, for safety violations other than privacy, and for Source Code findings.

Declared tools

ℹ

Approve an agent's tools on the Tools tab of its agent profile in Evidence Collection; see Declare the agent's tools. A change reaches the webhook within about 30 seconds. Names are compared ignoring case.

If the agent has approved tools (its declared tools), tool calls in the request history and in the response are checked against its tool permissions: approved and not expired, arguments within the argument rules and free of secrets, card numbers and social security numbers, and calls per minute within the limit.

Agent's policyA tool call that breaks a rule
Block or RedactFails the check
Audit Only, or no policyRecorded and allowed

Agents with no approved tools are not checked. With per-category actions, the policy's single action decides. Blocking is opt-in: give the agent a policy set to Block or Redact.

  • Approvals. Under Block or Redact, a response that asks for a tool that needs a person's approval fails the check (outcome approval_required) and an approval request is created on the agent's profile. It expires after 15 minutes. Once approved, the next call of that tool with the same arguments passes, once. See Approvals.
  • Group-limited tools always count as a violation, because the webhook does not know which user the agent acts for.
  • Rate limits are counted on responses, per agent and tool.

Violations from the webhook appear in AI Violations under the Tools filter, and raise the Tool misuse automation event.

Requests from unknown agents

Requests from unknown agents, under Guardrail behaviour on the connector page, decides what happens to a request ANTS cannot tie to a known agent:

  • the request has no agent_name in its metadata,
  • its agent_name matches no agent in the project, or
  • ANTS cannot look up the agent's policy.
SettingVerdict returned to Portkey
Allow (default)Pass
BlockFail

A lookup that runs out of time is still allowed under either setting, in the same way that Portkey allows a request when the webhook times out. Changing the setting needs connector write access (integrations.connectors:write) and is written to the audit log.

What is not checked

  • Requests for known agents with no policy and no approved tools pass without a check.
  • The webhook does not refuse a suspended agent's requests. An automatic suspension disables the agent's linked keys in Portkey, and Resume agent re-enables them (see Resume an agent); a suspension from Suspend agent does not disable them, so disable them here if they must stop. Requests without an agent_name, or with one that matches no agent, follow Requests from unknown agents.
  • ANTS answers within 2.5 seconds, including its own lookups, so it fits inside Portkey's 3-second timeout. If a check cannot finish in time, or a detection service fails, the request passes, unless a rule-based detector (Secrets & Credentials, Source Code or the card number and SSN checks) found something: those run inside ANTS on the full checked text, outside the time limit, so a rule-based Block still fails the check and a rule-based Redact still returns masked content. Ethics & Bias detection runs alongside and only fails a request when it answers in time; a later result is still recorded in AI Violations.
  • Only the last message of a request and the first choice of a response are checked and masked.
  • A new or changed policy can take up to 15 seconds to apply.
⚠

The agent_name in request metadata is supplied by the caller and cannot be verified by ANTS. Setting it in each key's default metadata makes the identity consistent, but a caller with the key can still send a different value in its request.

Managing the connection

  • Regenerate secret and Disconnect need step-up verification. After a secret is regenerated, the old one stops working within about 5 seconds.
  • Disconnecting, or changing the Portkey URL, is refused while ANTS has keys disabled. Enable them first, so no key is left disabled in Portkey without a record of its original expiry.

Other ways to use Budget AI with Portkey

You can instead move agent traffic to Budget AI, or place Budget AI in front of Portkey for agent traffic only. Both use Budget AI's own guardrail checks, and agents hold Budget AI keys. See Budget AI in front of another gateway.

© 2026 ANTS Platform, Inc.Docs v1.0 · Last updated June 2026