Files
wehub-resource-sync 0d3cb498a3
CI / Shell Format Check (push) Has been cancelled
CI / Check Ruby (3.4) (push) Has been cancelled
CI / CI Config (push) Has been cancelled
CI / Test on Node ${{ matrix.node }} and ${{ matrix.os }}${{ matrix.shard && format(' (shard {0}/3)', matrix.shard) || '' }} (push) Has been cancelled
CI / Build on Node ${{ matrix.node }} (push) Has been cancelled
CI / Style Check (push) Has been cancelled
CI / Generate Assets (push) Has been cancelled
CI / Check Python (3.14) (push) Has been cancelled
CI / Check Python (3.9) (push) Has been cancelled
CI / Build Docs (push) Has been cancelled
CI / Code Scan Action (push) Has been cancelled
CI / Site tests (push) Has been cancelled
CI / webui tests (push) Has been cancelled
CI / Run Integration Tests (push) Has been cancelled
CI / Run Smoke Tests (push) Has been cancelled
CI / Go Tests (push) Has been cancelled
CI / Share Test (push) Has been cancelled
CI / Redteam (Production API) (push) Has been cancelled
CI / Redteam (Staging API) (push) Has been cancelled
CI / GitHub Actions Lint (push) Has been cancelled
CI / Check Ruby (3.0) (push) Has been cancelled
release-please / release-please (push) Has been cancelled
release-please / build (push) Has been cancelled
release-please / publish-npm (push) Has been cancelled
release-please / publish-npm-backfill (push) Has been cancelled
release-please / docker (push) Has been cancelled
release-please / publish-code-scan-action (push) Has been cancelled
release-please / attest-code-scan-action (push) Has been cancelled
Deploy local.promptfoo.app / Deploy to Cloudflare Pages (push) Has been cancelled
Test and Publish Multi-arch Docker Image / test (push) Has been cancelled
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-amd64 platform:linux/amd64 runner:ubuntu-latest]) (push) Has been cancelled
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-arm64 platform:linux/arm64 runner:ubuntu-24.04-arm]) (push) Has been cancelled
Test and Publish Multi-arch Docker Image / merge-docker-digests (push) Has been cancelled
Test and Publish Multi-arch Docker Image / Attest Multi-arch Image (push) Has been cancelled
Validate Renovate Config / Validate Renovate Configuration (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:24:08 +08:00

2.8 KiB

sidebar_label, description
sidebar_label description
AI21 Labs Deploy AI21 Labs' Jamba models for enterprise text generation with task-specific optimization and control

AI21 Labs

The AI21 Labs API offers access to AI21 models such as jamba-mini and jamba-large.

API Key

To use AI21 Labs, you need to set the AI21_API_KEY environment variable, or specify the apiKey in the provider configuration.

Example of setting the environment variable:

export AI21_API_KEY=your_api_key_here

Model Selection

You can specify which AI21 model to use in your configuration. The current public aliases are:

  1. jamba-mini
  2. jamba-large

The provider also recognizes the versioned IDs jamba-mini-2, jamba-mini-2-2026-01, jamba-large-1.7, and jamba-large-1.7-2025-07.

Here's an example config that compares AI21 models:

providers:
  - ai21:jamba-mini
  - ai21:jamba-large

Options

The AI21 provider supports several options to customize the behavior of the model. These include:

  • temperature: Controls the randomness of the output.
  • top_p: Controls nucleus sampling, affecting the randomness of the output.
  • max_tokens: The maximum length of the generated text.
  • response_format: Set to { type: 'json_object' } for JSON output or { type: 'text' } for text output.
  • apiKeyEnvar: An environment variable that contains the API key.
  • apiBaseUrl: The base URL of the AI21 API.

Example Configuration

Here's an example configuration for the AI21 provider:

providers:
  - ai21:jamba-mini
    config:
      apiKey: your_api_key_here
      temperature: 0.1
      top_p: 1
      max_tokens: 1024
      response_format: { type: 'json_object' }

This configuration uses the jamba-mini model with a temperature of 0.1, top-p sampling with a value of 1, a maximum output length of 1024 tokens, and JSON-formatted output.

Cost

The cost of using AI21 models depends on the model and the number of input and output tokens. Here are the costs for the available models:

  • jamba-mini: $0.2 per 1M input tokens, $0.4 per 1M output tokens
  • jamba-large: $2 per 1M input tokens, $8 per 1M output tokens

You can override promptfoo's built-in pricing with inputCost and outputCost in the provider configuration. The legacy cost option still works as a shared fallback when you want the same rate for both directions.

Supported environment variables

These AI21-related environment variables are supported:

Variable Description
AI21_API_BASE_URL The base URL (protocol + hostname + port) to use for the AI21 API.
AI21_API_KEY AI21 API key.