Skip to main content

AI21 Labs: Powerful AI & API Integration Guide

AI21 Labs
info

For detailed information about using models with APIpie, check out our Models Overview and Completions Guide.

Description

AI21 Labs is a leading AI research company specializing in advanced language models. Their Jurassic-2 (J2) and Jamba series models leverage state-of-the-art technology to deliver exceptional performance in natural language processing and instruction-following tasks. The models are available through various providers integrated with APIpie's routing system.

The Jurassic-2 series offers powerful base models optimized for enterprise use, while the Jamba series represents their latest advancement in large language models, featuring extended context windows and enhanced instruction-following capabilities. Both series are built on AI21's proprietary training techniques and architectures detailed in their technical documentation.

Key Features

  • Extended Token Capacity: Models support context lengths from 8K to 256K tokens for handling various text processing needs.
  • Multi-Provider Availability: Accessible through platforms like Amazon Bedrock and OpenRouter.
  • Diverse Applications: Optimized for chat, instruction-following, and general text generation tasks.
  • Enterprise Focus: Models designed for production-ready deployment with consistent performance and reliability.

Model List in the AI21 Series

Model List updates dynamically please see the Models Route for the up to date list of models

info

For information about model performance and benchmarks, see the AI21 Labs Documentation.

Model NameMax TokensResponse TokensProvidersSubtypeType
j2-grande-instruct8,1928,192BedrockLLMLLM
j2-mid8,0008,191BedrockLLMLLM
j2-mid-v18,1928,192BedrockLLMLLM
j2-ultra-v18,1928,192BedrockLLMLLM
jamba-instruct-v1--BedrockLLMLLM
jamba-instruct256,0004,096OpenRouterChatXLLM
jamba-1-5-large256,0004,096OpenRouterChatXLLM
jamba-1-5-mini256,0004,096OpenRouterChatXLLM
jamba-1-5-large-v1256,0004,096BedrockLLMLLM
jamba-1-5-mini-v1256,0004,096BedrockLLMLLM

Example API Call

Below is an example of how to use the Chat Completions API to interact with a model from the AI21 Series, such as jamba-instruct.

curl -L -X POST 'https://apipie.ai/v1/chat/completions' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <YOUR_API_KEY>' \
--data-raw '{
"provider": "openrouter",
"model": "jamba-instruct",
"max_tokens": 150,
"messages": [
{
"role": "user",
"content": "Can you explain how photosynthesis works?"
}
]
}'

Response Example

The expected response structure for the AI21 model might look like this:

{
"id": "chatcmpl-12345example12345",
"object": "chat.completion",
"created": 1729535643,
"provider": "openrouter",
"model": "jamba-instruct",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Photosynthesis is the process by which green plants, algae, and some bacteria convert light energy into chemical energy. Here's how it works:\n\n1. **Light Absorption**: Plants capture light energy using a pigment called chlorophyll, which is found in chloroplasts.\n\n2. **Water and Carbon Dioxide**: They absorb water through their roots and carbon dioxide from the air.\n\n3. **Glucose Production**: The light energy is used to convert water and carbon dioxide into glucose (a sugar) and oxygen. The equation is:\n \n 6CO2 + 6H2O + light energy → C6H12O6 + 6O2\n\nThis process provides energy for the plant and releases oxygen into the atmosphere."
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 15,
"completion_tokens": 125,
"total_tokens": 140,
"prompt_characters": 45,
"response_characters": 520,
"cost": 0.002250,
"latency_ms": 3100
},
"system_fingerprint": "fp_123abc456def"
}

API Highlights

  • Provider: Specify the provider or leave blank for automatic selection.
  • Model: Use any model from the AI21 Series, such as jamba-instruct or others suited to your task. See Models Guide.
  • Max Tokens: Set the maximum response token count (e.g., 150 in this example).
  • Messages: Format your request with a sequence of messages, including user input and system instructions. See message formatting.

This example demonstrates how to seamlessly query models from the AI21 Series for conversational or instructional tasks.


Applications and Integrations

  • Conversational AI: Powering chatbots, virtual assistants, and other dialogue-based systems. Try it with LibreChat or OpenWebUI.
  • Enterprise Solutions: Leveraging AI21 Studio for customized AI applications and workflows.
  • Content Generation: Creating high-quality content with models optimized for natural language generation.
  • Extended Context Tasks: Processing long documents with models supporting up to 256K tokens. Learn more in our Models Guide.

Ethical Considerations

The AI21 models are powerful tools that should be used responsibly. Users should implement appropriate safeguards and consider potential biases in model outputs. For guidance on responsible AI usage, see AI21's Responsible use Guidelines.


Licensing

AI21 models are available through commercial licensing agreements. For detailed licensing information and terms of use, consult the AI21 Labs Terms of Service..

tip

Try out the AI21 models in APIpie's various supported integrations.