Skip to content
Back to Knowledge Base

Bring your own AI API key

Bring your own key routes self-healing CI through your own provider account, so inference bills to you instead of Nx Cloud.

It is a paid add-on, available on the Enterprise plan and enabled for your organization by Nx. Contact your developer productivity engineer to turn it on. The AI provider row does not appear in your organization settings until it is enabled.

Credentials reach fix-ci one of two ways. In stored mode Nx Cloud holds them for you, and in CI env mode they stay in your own CI secret store. Pick between them at /orgs/<org-id>/ai-provider, where they appear as Use your own AI provider and Supply your credentials in CI env.

PropertyStored in Nx CloudSet in your CI
Credential storageEncrypted in Nx CloudYour CI secret store, Nx stores nothing
Configured byAn organization admin, in the settings UIYour CI or platform team, on the fix-ci step
ProvidersAnthropic, AWS Bedrock, Azure AI FoundryAnthropic, AWS Bedrock, Azure AI Foundry, Google Vertex AI
IAM and STS authenticationNot supportedSupported

The Self-Healing CI AI provider setting, showing the CI env and Nx Cloud provider options

Google Vertex AI and AWS IAM or STS credentials are only available in CI env mode.

Self-healing CI uses three model tiers.

TierPurposeEnvironment variable
PrimaryFix generation. Use Opus, or Sonnet 4.5 and later.ANTHROPIC_DEFAULT_SONNET_MODEL
FallbackUsed when the primary is overloaded. Must differ from the primary.ANTHROPIC_DEFAULT_FALLBACK_MODEL
Low-powerBackground work such as classification and summaries. Usually Haiku.ANTHROPIC_DEFAULT_HAIKU_MODEL

The variable names are slots, not model families. The primary tier reads ANTHROPIC_DEFAULT_SONNET_MODEL whichever model you put in it, so an Opus ID belongs there. Self-healing CI does not read ANTHROPIC_DEFAULT_OPUS_MODEL.

Each tier takes the model identifier your provider publishes:

  • Anthropic: a Claude model name, from the Claude model list.
  • AWS Bedrock: a Bedrock model ID, shaped anthropic.<model>-<date>-v1:0.
  • Azure AI Foundry: the deployment name you gave the model.
  • Google Vertex AI: a Vertex model ID.

In stored mode you enter these as form fields, and in CI env mode you set the variables.

Select Use your own AI provider, then pick your provider and fill in the form. You need organization admin access, and a Claude model provisioned in your provider for each tier, which is a console step in AWS or Azure. Nx sets the runtime environment for every fix-ci run, so your CI configuration doesn't change.

To rotate a credential, use Replace credentials. Clearing the provider deletes the stored secret.

Set the provider variables wherever fix-ci runs. Nx stores nothing, and the Claude Agent SDK reads the variables at session start.

fix-ci runs in two places, so the variables have to be present in both. It runs on your main CI job for failures outside agents, meaning non-distributed commands, and on Nx Agents for distributed tasks that fail there. On the main job, set the variables the way you manage any other CI secret. Nx Agents start clean, so forward the variables to the agents. Forwarding covers Anthropic and Foundry outright. AWS and Vertex need more care on the agents, covered in their sections below.

In stored mode, supply an Anthropic API key. A gateway or proxy base URL is optional.

In CI env mode, set the following variables.

VariableRequiredValue
ANTHROPIC_API_KEYYesAnthropic API key
ANTHROPIC_BASE_URLNoGateway or proxy origin. Omit for api.anthropic.com
ANTHROPIC_DEFAULT_*_MODELNoThe three tiers. Unset falls back to the default Claude models

In stored mode, supply a long-term Bedrock API key as a bearer token, plus the AWS region. Short-term keys expire and break self-healing once they do.

In CI env mode, set the following variables.

VariableRequiredValue
CLAUDE_CODE_USE_BEDROCKYes1
AWS_REGIONYesRegion serving your models, such as us-west-2
AWS_BEARER_TOKEN_BEDROCKOne auth pathLong-term Bedrock API key as a bearer token
AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKENOne auth pathIAM or STS credentials
ANTHROPIC_DEFAULT_*_MODELYesBedrock model IDs

Through CI, fix-ci doesn't authenticate with a single key. It calls the AWS SDK, which walks the standard AWS credential chain to find whatever credentials the runner exposes, whether that's environment variables, a shared credentials file, or an attached role. CLAUDE_CODE_USE_BEDROCK and AWS_REGION only say where to go, and supplying the credentials is the part you set up.

On your own runners, the AWS SDK can use whatever the machine already carries, such as an attached instance or task profile, a ~/.aws file, or credentials your CI injects through OIDC. Often you set only the region and the Bedrock flag, and the existing AWS identity does the rest.

Nx Agents carry none of your AWS identity, so pass the credentials as environment variables. A long-term Bedrock API key in AWS_BEARER_TOKEN_BEDROCK is the shortest path. For IAM or STS, mint short-lived credentials on your main job and forward AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN, and AWS_REGION to the agents.

The host is services.ai.azure.com, not openai.azure.com. Model values are deployment names, one per tier.

The endpoint takes a resource name such as my-resource, or a bare origin such as https://my-resource.services.ai.azure.com, with no path. Nx and the Claude Agent SDK append /anthropic/v1/messages themselves, so a stored /anthropic doubles and returns a 404. The Nx Cloud form rejects a path and previews the resolved URL before you save.

In stored mode, supply a Foundry API key and an endpoint in either of those two forms.

In CI env mode, set the following variables.

VariableRequiredValue
CLAUDE_CODE_USE_FOUNDRYYes1
ANTHROPIC_FOUNDRY_RESOURCEOne of these twoResource name only, such as my-resource. The SDK derives the origin
ANTHROPIC_FOUNDRY_BASE_URLOne of these twoBare origin, no path. Use for a custom origin
ANTHROPIC_FOUNDRY_API_KEYYesFoundry API key
ANTHROPIC_DEFAULT_*_MODELYesFoundry deployment names

Vertex has no Nx Cloud form, so it runs in CI env mode only.

VariableRequiredValue
CLAUDE_CODE_USE_VERTEXYes1
ANTHROPIC_VERTEX_PROJECT_IDYesGoogle Cloud project ID
CLOUD_ML_REGIONYesglobal, a multi-region such as us or eu, or a region such as us-east5
GOOGLE_APPLICATION_CREDENTIALSYesPath to a service account key file, unless Application Default Credentials are present
ANTHROPIC_DEFAULT_*_MODELYesVertex model IDs

Current models take the bare identifier, such as claude-sonnet-5. A dated snapshot separates the date with @, shaped claude-<model>@<date>.

Authentication goes through the Google credential chain, which usually wants a service account key file rather than a single value. On your own runners, use Application Default Credentials through gcloud auth application-default login, or point GOOGLE_APPLICATION_CREDENTIALS at a key file already on the machine.

Forwarding to Nx Agents passes values, not files, so carry the key file as a value and rebuild it on the agent:

  1. Put the service account JSON into an environment variable. Base64-encode it to avoid newline and quoting problems.
  2. Forward that variable to the agents.
  3. In the init step of your launch template, decode the value back out to a file and point GOOGLE_APPLICATION_CREDENTIALS at that path.

For region and model details, see Claude on Google Vertex AI.

Open a CI pipeline execution and check the self-healing tab for fix suggestions. Your nx fix-ci step should run without logging errors about a missing or rejected provider.

Last updated: