POST
/
studio
/
v1
/
assistants
/
{assistant_id}
/
run
import requests

assistant_id = "your-assistant-id"
api_key = "your-api-key"

url = f"https://api.ai21.com/studio/v1/assistants/{assistant_id}"

headers = {
    "Authorization": f"Bearer {api_key}",
    "Content-Type": "application/json"
}

payload = {
    "input": [
        {
            "role": "user",
            "content": "string"
        }
    ],
    "output_type": "json",
    "include": [
        "data_sources",
        "requirements_result",
        "requirements_result.metadata"
    ]
}

response = requests.post(url, headers=headers, json=payload)

print("Status Code:", response.status_code)
print("Response:", response.json())

Path Parameters

assistant_id
string
required
The unique identifier of the assistant to invoke.
Use agent_id when you want repeatable behavior without re-specifying name, instructions, tools, or the tool config each call.
When you invoke an assistant_id and override a specific configuration (for example, updating only the requirements), the assistant uses your updated value for that field, while all other settings (such as name, description, and budget) are still taken from the assistant_id.

Request Body

input
object[]
required
A list of message objects. Each object must include a role and content.
output_type
object
Reserved for specifying structured output format.
include
string[]
Specify which extra fields should be included in the output. If not provided, none of these fields will be included. Supported values:
  • data_sources — Includes the data_sources field in the output.
  • requirements_result — Includes detailed results for each requirement in the requirements_result field.
    import requests
    
    assistant_id = "your-assistant-id"
    api_key = "your-api-key"
    
    url = f"https://api.ai21.com/studio/v1/assistants/{assistant_id}"
    
    headers = {
        "Authorization": f"Bearer {api_key}",
        "Content-Type": "application/json"
    }
    
    payload = {
        "input": [
            {
                "role": "user",
                "content": "string"
            }
        ],
        "output_type": "json",
        "include": [
            "data_sources",
            "requirements_result",
            "requirements_result.metadata"
        ]
    }
    
    response = requests.post(url, headers=headers, json=payload)
    
    print("Status Code:", response.status_code)
    print("Response:", response.json())