Using AI21 with Flowstack

AI21 can be seamlessly integrated with Flowstack using REST API, Python, or Node.js. Below are the implementation details for each method.

1. Using REST API

To make a request to AI21 using the REST API, use the following Curl command. Ensure you replace YOUR_AI21_API_KEY with your actual AI21 API key.

curl -X POST "" \
-H "Authorization: Bearer YOUR_AI21_API_KEY" \
-H "Content-Type: application/json" \
-H "Flowstack-Auth: Bearer YOUR_FLOWSTACK_KEY" \
-d '{"prompt": "Hello!"}'

2. Using Python

For integrating AI21 with Python, use the script below. Replace YOUR_AI21_API_KEY and YOUR_FLOWSTACK_KEY with your AI21 API key and Flowstack key, respectively.

import requests
import json

url = ""

headers = {
    "Authorization": "Bearer YOUR_AI21_API_KEY",
    "Content-Type": "application/json",
    "Flowstack-Auth": "Bearer YOUR_FLOWSTACK_KEY"
payload = {
    "prompt": "Hello!"

response =, headers=headers, data=json.dumps(payload))

3. Using Node.js

For Node.js integration with AI21, follow the example below. Don’t forget to replace YOUR_AI21_API_KEY and YOUR_FLOWSTACK_KEY with your respective credentials.

const axios = require('axios');

const url = "";

const headers = {
    Authorization: "Bearer YOUR_AI21_API_KEY",
    "Content-Type": "application/json",
    "Flowstack-Auth": "Bearer YOUR_FLOWSTACK_KEY"

const payload = {
    prompt: "Hello!"
};, payload, { headers: headers })
    .then(response => {
    .catch(error => {
        console.error('Error:', error);