Skip to content

OpenAI Assistants API

The ai CLI allows you to create, manage, and interact with OpenAI's Assistants API.

Prerequisites

Before you begin, you'll need to install the ai CLI and set up Azure OpenAI.

Install the ai CLI
Setup Azure OpenAI

Listing, creating, updating, and deleting assistants

List all assistants
ai chat assistant list
Create an assistant
ai chat assistant create --name MyAssistant
Update an assistant
ai chat assistant update --instructions @instructions.txt
Delete an assistant
ai chat assistant delete --id ID

See the persisted config from ai chat assistant create/update

View assistant configuration
ai config @assistant.id

Picking a new assistant

List all assistants
ai chat assistant list
Set assistant by ID
ai config --set assistant.id ID

Clearing the assistant ID from the config

Clear assistant ID
ai config --clear assistant.id
TODO: Finish this section on differences between chat completions and assistants.

Differences between chat completions and assistants
◦ stateless vs stateful
◦ customer controlled chat history vs threads
◦ automatic context window management
◦ advanced features: code interpreter, function calling, file search