Documentation

AI Gateway Setup

Connect OpenAI, Anthropic, OpenRouter or AWS Bedrock to the ZopNight AI Gateway. Lists the exact key type or AWS access each provider needs, and how your developers point their tools at the gateway.

The AI Gateway sits between your developers and your AI providers. You connect a provider once. Your developers then use a ZopNight virtual key instead of the provider key. Each virtual key has its own budget and list of allowed models, and every request shows up in AI spend reports.

Before you start

NeedDetail
A ZopNight AdminOnly Admins connect providers and manage models. Editors create virtual keys.
A provider accountOpenAI, Anthropic, OpenRouter, or an AWS account with Bedrock.
For Bedrock: a connected AWS accountConnected under Cloud Accounts. A read-only connection also needs the AI Gateway permissions.
Outbound HTTPS for your developersTheir tools call https://api.zop.dev/ai-gateway. Nothing calls into your network.

Access to grant

OpenAI, Anthropic and OpenRouter

Each provider needs one API key. Before saving it, ZopNight makes one read call with the key, and rejects a key the provider refuses.

ProviderKey to createMinimum access
OpenAIA project API keyAll, or Restricted with the two permissions below
AnthropicA standard API keyA normal key from the Claude Console
OpenRouterA standard API keyA normal key

For an OpenAI Restricted key, turn on these two, as named in OpenAI's permission list:

  • List models: Read. Without it the key is rejected when you connect.
  • Model capabilities: Request. This is what lets the gateway call chat completions.

For Anthropic, use a normal API key. An Admin key (sk-ant-admin…) is for the Admin API, not for calling models.

The connect check calls:

The key is stored encrypted. It is never shown again in ZopNight or sent to your developers.

AWS Bedrock

Bedrock needs no key. ZopNight calls it with your connected AWS account's credentials: the ZopNight role (short-lived credentials, refreshed before they expire) or, for a connection made with access keys, that IAM user's keys.

IAM actionWhyGranted on
bedrock:ListFoundationModelsFind usable modelsEvery connection
bedrock:ListInferenceProfilesFind cross-region IDsEvery connection
bedrock:GetFoundationModelAvailabilityHide models AWS will not serve the account (optional: without it every model is listed)Every connection (also in AWS ReadOnlyAccess)
bedrock:InvokeModelCall a modelRead and write only
bedrock:InvokeModelWithResponseStreamStream a responseRead and write only
aws-marketplace:Subscribe, aws-marketplace:Unsubscribe, aws-marketplace:ViewSubscriptionsEnable a third-party model on first useRead and write only

The list actions and GetFoundationModelAvailability are in the ZopNight role's read policy. The rest are in its write policy. The Marketplace actions are the ones AWS lists as model access prerequisites. AWS can only narrow aws-marketplace:Subscribe by Marketplace product ID, one per model, so the role grants it unscoped. If your security review needs it scoped, add an aws-marketplace:ProductId condition for the models you use. AWS needs these actions only the first time a model is used in an account. You can attach them, use each model once, then remove them.

Action names are from Actions, resources, and condition keys for Amazon Bedrock.

Connections made with access keys

ZopNight cannot change an IAM user's permissions. Attach this policy to the user whose keys you connected. Manage models uses the List actions to find your models. Skip that statement if the user already has them, for example through ReadOnlyAccess.

IAM policy for Bedrock through the AI Gateway
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "BedrockDiscover",
      "Effect": "Allow",
      "Action": ["bedrock:ListFoundationModels", "bedrock:ListInferenceProfiles", "bedrock:GetFoundationModelAvailability"],
      "Resource": "*"
    },
    {
      "Sid": "BedrockInvoke",
      "Effect": "Allow",
      "Action": ["bedrock:InvokeModel", "bedrock:InvokeModelWithResponseStream"],
      "Resource": "*"
    },
    {
      "Sid": "BedrockModelAccess",
      "Effect": "Allow",
      "Action": [
        "aws-marketplace:Subscribe",
        "aws-marketplace:Unsubscribe",
        "aws-marketplace:ViewSubscriptions"
      ],
      "Resource": "*"
    }
  ]
}

You can also skip the Marketplace actions. Have someone with Marketplace rights enable each third-party model once by invoking it from the Bedrock console. For Anthropic models, also complete the First Time Use form. After that, the user's keys need only the bedrock: actions.

You also need the models available in your AWS account. See Access Amazon Bedrock foundation models:

  • Amazon Nova models work as soon as Bedrock is available in your account.
  • Anthropic Claude models need the one-time First Time Use form first. The first call to a third-party model also starts an AWS Marketplace subscription, which the ZopNight role creates for you on read-and-write connections.
  • ZopNight registers each default model under an ID AWS offers in your region: a regional profile such as us., eu., apac. or in. when there is one, otherwise global.. Models you add under Manage models can be any ID AWS lists for your region. global. ones need access to the model in every Region of the profile. If a Service Control Policy blocks some of those Regions, requests fail.

Set it up

  1. Connect a provider

    Open Settings → Integrations → AI Providers and click Connect on the provider tile. Enter the API key. For Bedrock, pick the AWS account and the Region instead. Click Connect. ZopNight checks the key and adds a default set of models. The toast says how many were added. If the tile shows Connected · no models, the models could not be added and the toast says why. Fix the cause, then choose Add default models from the tile menu.

  2. Add or remove models (optional)

    For OpenRouter and Bedrock, open the tile menu and choose Manage models. Add a model by picking it from the list or entering its ID.

  3. Create a virtual key

    Open AI Estate → Inference Keys and click Create virtual key. Give it a name, the models it may use, and a budget. The key is shown once. Copy it. Rotating a key issues a new secret. The new key keeps the old key's spend and its daily, weekly or monthly reset.

  4. Point your tools at the gateway

    Use the gateway address and the virtual key in place of the provider's. The key screen shows ready-made snippets for Claude Code, the OpenAI SDK and cURL.

Claude Code · bash
export ANTHROPIC_BASE_URL=https://api.zop.dev/ai-gateway
export ANTHROPIC_AUTH_TOKEN=<your virtual key>
export ANTHROPIC_MODEL=<a model name from the key>
export ANTHROPIC_DEFAULT_HAIKU_MODEL=<a Haiku model name from the key, else the same model name>
claude
OpenAI SDK · python
from openai import OpenAI

client = OpenAI(base_url="https://api.zop.dev/ai-gateway", api_key="<your virtual key>")

Usage appears under AI Estate → AI Usage; spend under Costs → Reports → AI Spend.

Cap spend across the organization

  • AI Estate → Inference Keys → Org budget ceiling sets one hard cap on all virtual keys combined.
  • Only admins can set or remove it.
  • Once the total is spent, the gateway refuses requests until the period resets.
  • Period is monthly, weekly, daily, or No reset for a lifetime cap.
  • Per-key budgets still apply within the ceiling.
  • Remove ceiling is in the same drawer and asks you to confirm.

Disconnect and remove access

Settings → Integrations → AI Providers → Disconnect removes the provider, its models, and the stored key or AWS credentials from ZopNight.

  • Virtual keys stay, but requests to the removed models fail.
  • ZopNight does not revoke anything at the provider. Delete the API key in the provider's console.
  • For Bedrock, the short-lived AWS credentials expire within an hour. For a connection made with access keys, deactivate the key in IAM.

Troubleshooting

ProblemCause and fix
<provider> rejected this API key, e.g. OpenAI rejected this API keyFor an OpenAI Restricted key, turn on List models. For Anthropic, use a normal API key.
Bedrock requests return access deniedThe AWS connection is read-only, its stack predates the streaming permission, or the access-key user lacks the policy above.
Claude on Bedrock works once, then is denied (Marketplace)Complete the First Time Use form. Then update the ZopNight stack, or attach the policy above to the access-key user, so the Marketplace subscription can be created.
The Bedrock tile shows Connected · no modelsThe default models could not be added. The toast names the cause. Fix it, then choose Add default models from the tile menu.
Connect is greyed outConnecting needs permission to create cloud accounts and AI models (the Admin role has both), and the console must not be in read-only mode.
Add default models is greyed outIt needs permission to create AI models, and the console must not be in read-only mode.