Skip to main content
Version: Dev

Provider Keys

A provider key stores the credential and connection settings AISIX uses to call a provider. Multiple model aliases can share one provider key. Applications authenticate to AISIX with caller API keys, which keeps upstream credentials out of application code.

Prerequisites​

  • Obtain a credential from your upstream provider.
  • In AISIX Enterprise or AISIX Cloud, obtain permission to create organization provider keys and access to the environment where the model will run. For an Enterprise installation, follow Get Started with AISIX Enterprise. To request AISIX Cloud access, contact API7.
  • In AISIX OSS, prepare a gateway that loads resources.yaml. The AISIX OSS quickstart covers validation and reload.

Create a Provider Key​

Create an OpenAI provider key named openai-prod, confirm that AISIX saved it, then use it in a model request.

The provider key belongs to the organization. Grant access to the environments whose models will use it.

  1. Under Organization, open Provider keys, then select New provider key.

  2. Enter openai-prod in Display name and select OpenAI in Provider. Enter the provider credential in Upstream API key.

  3. Under Allowed environments, select each environment where models will use the key. This example selects prod.

    New provider key form with OpenAI selected, the upstream credential masked, and prod checked
  4. Select Create provider key. Verify the display name, provider, and allowed environments in the list.

Saved openai-prod provider key in the list with OpenAI and prod

Verify the Provider Key​

  1. Create a model that uses the provider key.

  2. Create a caller API key with access to that model alias.

  3. Export the plaintext caller key as AISIX_API_KEY.

    export AISIX_API_KEY="YOUR_CALLER_API_KEY"
  4. Send a request with the caller key and confirm that the upstream returns a successful response.

The successful upstream response verifies that the provider credential, endpoint, model reference, and caller access work together. Repeat this request after changing the endpoint or configuring an override. To verify a reasoning override, send a streaming Chat Completions request and confirm that the response contains delta.reasoning_content.

Credential Handling​

Assign an owner to each upstream credential, especially when several models share one key. An in-place rotation affects every model that uses the key.

  • AISIX Enterprise and AISIX Cloud. AISIX encrypts the upstream credential before storing it. Read endpoints return the key's settings but omit the credential. They leave default request-header and body-field names visible and mask their values as ***. See Change the Configuration Later to edit masked values. Supply a non-empty credential when you replace it.
  • Bedrock and Vertex AI catalog keys. In AISIX Enterprise and AISIX Cloud, supply the credential fields in config and omit api_key. A Bedrock configuration can also select a Bedrock API key or the gateway's AWS credentials. See Choose a Credential Mode.
  • AISIX OSS. Store the credential in an environment variable and reference it in the resources file. For a structured credential, store the JSON string in the environment variable referenced by api_key.

Set Provider and Adapter​

The provider identifies the upstream. The adapter determines the API format AISIX uses to call it, such as OpenAI, Anthropic, or Bedrock.

For a known upstream, select its catalog provider. The catalog includes native integrations and community entries from models.dev. AISIX selects the adapter, including for providers with an OpenAI-compatible API such as DeepSeek.

For a private or custom upstream, select Bring your own upstream (private endpoint), choose the Protocol adapter that matches the upstream API, and enter its API base. To change the adapter later, create a replacement key and update the models and passthrough routes that reference the old key.

New provider key form with a private upstream, required API base, and OpenAI-compatible protocol adapter

Configure the Base URL​

The base URL is the default address for upstream requests. Use the URL shape the adapter expects. If the provider serves a second protocol at a separate path, configure a separate URL for that API surface.

When to Set a Base URL​

AISIX Enterprise and AISIX Cloud use the catalog base URL when one is available. For AISIX OSS, check the provider setup guide for the URL the gateway can derive.

Set an explicit base URL in either of these cases.

  • The catalog entry supplies a URL template. Examples include Databricks, Neon, Snowflake Cortex, Cloudflare Workers AI, and infomaniak.
  • The key points to a private endpoint or an upstream proxy.

For a catalog entry with a URL template, the dashboard marks API base as required. The Admin API returns HTTP 400 if the create request omits the URL or an update clears it.

Use the upstream root. AISIX normalizes trailing slashes and common full endpoint paths.

In Provider keys, create or edit the key. Enter the upstream root in API base, then save.

Common Base URLs​

Use the base URL format for the selected adapter.

Upstream APIAdapterBase URL
OpenAIopenaihttps://api.openai.com/v1
DeepSeekopenaihttps://api.deepseek.com
Gemini OpenAI-compatible APIopenaihttps://generativelanguage.googleapis.com/v1beta/openai
Anthropicanthropichttps://api.anthropic.com
Azure OpenAIazure-openaihttps://<resource>.openai.azure.com
AWS Bedrockbedrockhttps://bedrock-runtime.<region>.amazonaws.com
Google Vertex AIvertexRegional: https://<region>-aiplatform.googleapis.com; global: https://aiplatform.googleapis.com; multi-region: https://aiplatform.us.rep.googleapis.com or https://aiplatform.eu.rep.googleapis.com

For Bedrock, the control plane can derive the endpoint from the credential's region when you leave the base URL empty. In AISIX OSS, the AWS SDK derives the same endpoint. See AWS Bedrock.

Allow for DNS Refresh​

Most upstream HTTP clients share a DNS cache. A successful lookup is cached for 30 seconds regardless of the record's TTL. A failed lookup is cached for one second.

These cache settings do not cover every transport:

  • Bedrock and Realtime use separate clients.
  • With a forward proxy, the proxy resolves the upstream hostname itself.

Pin the Endpoint Addresses​

Use private DNS when you can publish a record for the provider's hostname. Otherwise, retain that hostname in the base URL and pin the private link's addresses on the provider key. See Protected Header Names for how AISIX handles the Host header.

  • Enter IPv4 or IPv6 address literals without brackets or ports.
  • List addresses in order of preference. If a connection attempt fails, AISIX can try another address. With both IPv4 and IPv6 entries, the client can try the alternate address family in parallel.
  • Keep the scheme, hostname, and any custom port in the base URL. The hostname still identifies the upstream for TLS and certificate verification. The HTTP host or authority also retains any custom port.

In Provider keys, edit the key. Under Endpoint addresses, enter one address per line in order of preference, then save. To return to DNS resolution, clear the field and save again.

Provider key edit form with API base and two endpoint addresses

Understand the Scope​

The pinned addresses apply to the hostname in the base URL. Other API surfaces on that hostname share the pinned addresses. An API surface on a different host uses normal DNS resolution.

CaseBehavior
Base URL already contains an IP addressAISIX Enterprise and AISIX Cloud reject the combination because pinning requires a hostname. In AISIX OSS, the configuration loads, but the addresses have no hostname to replace and do not affect connections.
Bedrock provider keyAISIX Enterprise and AISIX Cloud reject the field. In AISIX OSS, the field has no effect because Bedrock uses the AWS transport, which also bypasses per-key TLS settings.
RealtimeA separate transport resolves the endpoint and uses deployment-wide TLS settings.
Forward proxyThe proxy resolves the upstream hostname. See Forward Proxy for IDE AI Traffic.

Declare the API Surfaces​

A provider can serve several APIs under one credential. A surface declaration tells AISIX which APIs the endpoint serves natively and which URLs to use. For example, forwarding to a native Anthropic Messages endpoint preserves features such as cache breakpoints and signed thinking.

Set the Surface URLs​

Each surface uses the key's default base URL unless you supply a separate URL. The following example configures a DeepSeek key to serve Responses at its default URL and Messages at its Anthropic-compatible path.

  1. In Provider keys, open the deepseek-prod key. If it does not exist, select New provider key, then enter deepseek-prod as the Display name, select DeepSeek as the Provider, enter the upstream credential, set API base to https://api.deepseek.com, and select the allowed environments.

  2. Expand API surfaces. If Declare this endpoint's API surfaces is not already selected, select it.

  3. Ensure Responses API (/v1/responses) is selected and leave its Base URL empty.

  4. Ensure Anthropic Messages API (/v1/messages) is selected and set its Base URL to https://api.deepseek.com/anthropic.

    API surfaces section with Responses and Anthropic Messages selected and a separate Messages base URL
  5. Save the key.

All three request types use the same upstream model name.

Caller routeUpstream URL
/v1/chat/completionshttps://api.deepseek.com/chat/completions
/v1/messageshttps://api.deepseek.com/anthropic/v1/messages
/v1/responseshttps://api.deepseek.com/v1/responses

Decide Which APIs to Forward Natively​

Some upstreams expose Responses or Messages on routes that AISIX cannot infer from the provider and adapter alone. Declare only the routes AISIX should forward natively.

Responses​

First confirm whether the upstream exposes /v1/responses. If it does, include responses in the declaration so AISIX forwards calls there natively. If it does not, create the declaration without responses; AISIX then translates the calls to Chat Completions. Declaring a route that does not exist can return an upstream HTTP 404. Codex Lite-mode tool requests are an exception with separate forwarding rules.

For an OpenAI-compatible endpoint that serves only Chat Completions, enable Declare this endpoint's API surfaces, leave both surfaces unselected, then save.

API surfaces section with the declaration enabled and both optional surfaces unselected

Messages​

Anthropic providers and adapters already send Messages and Count Tokens natively, so they need no declaration. With another adapter that supports surface declarations, add messages only when the upstream implements both routes and accepts Anthropic-compatible authentication. AISIX then passes the provider credential in x-api-key and sends the anthropic-version header by default.

For a Messages endpoint that requires bearer authentication or serves only one of the two routes, use an authenticated passthrough route.

APIs Outside Surface Declarations​

Leave other APIs out of surface declarations. Chat Completions, embeddings, audio, images, video, files, batches, fine-tuning, and rerank continue to use the default base URL. Bedrock, Vertex AI, and Azure OpenAI translate requests to their platform APIs automatically, so the Admin API rejects surface declarations for those adapters. Claude Messages and Count Tokens on Bedrock or Vertex AI still use the platform's Anthropic Messages API.

Keep or Override Catalog Defaults​

If you do not declare surfaces yourself, AISIX uses the catalog when one applies, then falls back to the provider and adapter defaults. See Provider Behavior for the Responses defaults.

For AISIX Enterprise and AISIX Cloud, a DeepSeek key at the vendor's catalog URL uses the catalog's curated declaration. The dashboard identifies a declaration supplied by AISIX. Editing it makes the declaration operator-managed. Clearing it returns the key to the curated declaration when the endpoint still qualifies for one.

Changing API base to a custom endpoint stops the curated declaration from applying. An operator-managed declaration remains in effect.

Configure Provider-Specific Overrides​

Configure provider-key overrides when the upstream request or response differs from the adapter's format. Every model that references the key inherits its overrides.

The following example adapts requests and streaming responses for a custom OpenAI-compatible upstream. Start with an existing BYO key from Bring Your Own Endpoint, then update it through the same management workflow.

  1. In Provider keys, create or edit the Bring your own upstream (private endpoint) key. For a new key, enter its display name, credential, API base, and allowed environments, then choose the openai option under Protocol adapter.

  2. Expand Advanced wire-shape overrides.

  3. In Request override JSON, rename max_completion_tokens to the upstream's max_tokens. If a caller sends both fields, AISIX keeps max_completion_tokens:

    {
    "param_renames": {
    "max_completion_tokens": "max_tokens"
    }
    }

    For reasoning models on the OpenAI provider or Azure OpenAI adapter, AISIX applies the built-in token cap conversion before this custom rename.

  4. In Response override JSON, map upstream streaming reasoning from delta.thinking to delta.reasoning_content in the AISIX response:

    {
    "reasoning_field": "delta.thinking"
    }
    Advanced wire-shape overrides section with request parameter renaming and response reasoning mapping
  5. Save the key.

Available fields vary by adapter, request path, and management path. For the complete field set, use the Admin API reference for managed keys or the Resources File Reference for AISIX OSS. Header generation and forwarding are covered in Configure Upstream Request Headers.

After saving, verify the provider key with a representative request through a non-production alias before sharing it across models.

Next Steps​

  • To connect another upstream, choose its guide in Provider Setup for credential and endpoint requirements.
  • Use Provider Key Rotation to update a credential in place or move models and passthrough routes to a replacement key in stages.
  • In AISIX Enterprise and AISIX Cloud, create a budget with Provider key scope to track upstream spend or block calls through the key once it reaches its limit.