Know of an official OpenAPI document? Contribute it →
For Agents
Run chat completions against AI21's language models, generate text embeddings, tokenize and detokenize text, and manage documents in the retrieval library.
Use for: Generate a chat completion for this prompt, Create embeddings for these documents, Count the tokens in this text before sending it, Upload a document to the retrieval library
Not supported: Does not fine-tune models, host inference endpoints, or manage billing. Use for AI21 text generation, embeddings, and retrieval only.
Jentic publishes the only available OpenAPI specification for AI21 Labs API, keeping it validated and agent-ready. The AI21 Labs API runs large language model chat completions and text embeddings, tokenizes and detokenizes text, and manages a document library for retrieval. It gives agents direct access to AI21's language models for generation and semantic search.
Install Jentic One Beta
Jentic One is a self-hosted execution layer for AI agents. It lets your agent call the AI21 Labs API, or any other public or private API you need. You set the rules, the agent never sees your credentials, and every call is logged.
Two steps, two machines. Install the instance in a safe environment, then register your agent from wherever it runs.
Step 1: Jentic One Host machine
# On the machine that will host your Jentic One instance:
curl -fsSL "https://jentic.com/install.sh?src=apis&api=%2Fapis%2Fai21.com%2Fai21" | shStep 2: Agent machine
# On the machine where your agent runs (keep this separate from the instance):
curl -fsSL "https://jentic.com/install.sh?src=apis&api=%2Fapis%2Fai21.com%2Fai21" | sh
jentic register # connects your agent to your Jentic One instanceJentic One is in public beta. The setup above keeps your agent separate from the instance, which is what you want before using real credentials: an agent running as the same OS user as Jentic One can read its stored keys directly. Just evaluating? A single local install is fine to start. See the secure deployment guide for the tiers.
What an agent can do with AI21 Labs API.
Run chat completions against AI21's language models
Generate text embeddings for semantic search and retrieval
Tokenize and detokenize text to manage context length
Upload and manage documents in the retrieval library
Retrieve a previous chat completion by its request identifier
Patterns agents use AI21 Labs API for, with concrete tasks.
★ Agent Language Generation
An AI agent can call the chat completion operation to summarize, rewrite, or answer from a prompt using AI21's language models. Because the request and response formats are structured, the agent can chain generation into a larger workflow without bespoke parsing. Through Jentic the agent discovers the completion operation by intent and runs it with the token injected at call time.
Generate a summary of this support ticket using a chat completion
Semantic Search Over Documents
An agent can embed a set of documents, store them in the retrieval library, and later embed a query to find the most relevant passages. This gives retrieval-augmented answers without standing up a separate vector database. The agent works only with the files it uploads.
Embed these 20 FAQ entries and store them for retrieval
Context-Length Management
Before sending a long prompt, an agent can tokenize the text to measure its length and trim it to fit the model's context window, then detokenize when it needs to inspect tokens. This avoids failed requests from oversized inputs. The check runs as a lightweight preflight step.
Tokenize this document and tell me if it fits the model's context window
7 endpoints — jentic publishes the only available openapi specification for ai21 labs api, keeping it validated and agent-ready.
METHOD
PATH
DESCRIPTION
/chat/completions
Run a chat completion
/embed
Generate text embeddings
/tokenize
Tokenize text
/detokenize
Convert tokens back to text
/library/files
List documents in the retrieval library
/library/files
Upload a document to the retrieval library
/chat/completions
Run a chat completion
/embed
Generate text embeddings
/tokenize
Tokenize text
/detokenize
Convert tokens back to text
/library/files
List documents in the retrieval library
/library/files
Upload a document to the retrieval library
What agents get from Jentic-routed access to this vendor.
Setup
Wiring the AI21 Labs API by hand means obtaining a bearer token, setting the Authorization header on every request, and handling the completion, embedding, and library request formats yourself. Through Jentic you install once, import AI21 from the API Directory, store the token once, and your agent calls it.
Permission scoping
AI21 carries each request's input in the body rather than the URL path, so rules bound which operations the agent may call. You can allow completions and embeddings while keeping the agent out of the document library, or restrict it to read-only library access.
Credential isolation
Your AI21 bearer token is stored once, encrypted, by your own Jentic One instance and injected at execution time. It never enters the agent's prompt, logs, or context.
Intent-based discovery
Agents search Jentic by intent such as 'generate a chat completion' or 'create text embeddings', and Jentic returns the matching AI21 Labs operation with its input schema so the agent calls the right endpoint without reading the reference docs.
Alternatives and complements available in the Jentic catalogue.
Specific to using AI21 Labs API through Jentic.
Why is there no official OpenAPI spec for AI21 Labs API?
AI21 Labs does not publish an OpenAPI specification. Jentic generates and maintains this spec so that AI agents and developers can call the AI21 Labs API via structured tooling. It is validated against the live API and kept up to date. To run it on your own infrastructure, install Jentic One from its GitHub repo.
Is there an AI21 Labs MCP server?
You don't need an MCP server to give your agent the AI21 Labs API. Jentic connects it directly from the API Directory: import it, store your bearer token once, and your agent runs completions and embeddings. No extra server sits in the agent's context.
Can I limit what my agent is allowed to do with the AI21 Labs API?
Yes. You choose which operations the agent may call, so it can be allowed to run completions and embeddings while being kept out of the document library, or restricted to read-only library access. Requests carry their input in the body rather than the URL path, so rules bound which operations the agent may use. Every call is logged.
What authentication does the AI21 Labs API use?
The AI21 Labs API authenticates with a bearer token in the Authorization header, per its OpenAPI spec. Through Jentic the token is stored encrypted by your own Jentic One instance and injected when the agent makes a call, so it never appears in the agent's prompt or logs.
Can my agent do semantic search with the AI21 Labs API?
Yes. The embeddings operation turns text into vectors, and the document library stores files for retrieval, so an agent can embed a query and find the most relevant passages without a separate vector service.
What are the rate limits for the AI21 Labs API?
The OpenAPI spec does not specify rate limits; AI21 applies per-plan quotas. Check the AI21 Labs documentation for the current limits before scaling an agent's usage.
How does my agent run a completion with the AI21 Labs API through Jentic?
Search Jentic for 'generate a chat completion' and it returns the AI21 Labs completion operation with its input schema. Store your bearer token once, then the agent sends a prompt and reads back the generated text.
GET STARTED