Skip to main content

Basic Usage

For all the assistant applications created on TaskingAI, you can interact with them through the OpenAI-compatible API. This API is designed to be stateless and compatible with OpenAI's chat completion API, so you can use the same SDKs and libraries that you would use with OpenAI's API, making it easier to migrate your agents to TaskingAI with minimum changes in code.

To obtain the assistant_id, navigate to the management page of the created application in your project. You can find the assistant_id in the URL. For example, in the URL https://app.tasking.ai/projects/pX******/assistants/X5lMJvqeJlZ6tKPu********/records, the assistant_id is X5lMJvqeJlZ6tKPu********.

Initialize the OpenAI Client

To use the OpenAI-compatible API through the OpenAI SDK, you need to initialize the OpenAI client with your TaskingAI API key and set the base URL to https://oapi.tasking.ai.

from openai import OpenAI

client = OpenAI(
api_key="YOUR_TASKINGAI_API_KEY",
base_url="https://oapi.tasking.ai/v1",
)

Specify the Assistant

With TaskingAI's OpenAI-compatible API, you can interact with any of the models or assistants. All you need to do is provide the assistant ID to the model parameter in the request body.

response = client.chat.completions.create(
model="YOUR_TASKINGAI_ASSISTANT_ID",
messages=[
{"role": "user", "content": "Hello, how are you?"},
]
)

print(response)

For detailed information about the response schema, please refer to OpenAI's chat completion API reference.

note

The generation will be treated as a stateless agent invocation, and no chat history will be stored.

Manage Assistant

The TaskingAI Python SDK provides a convenient way to interact with your existing assistant applications.

Before integrating with the SDK, you need to create an assistant application in the corresponding project on the TaskingAI platform.

To obtain the assistant_id, navigate to the management page of the created application in your project. You can find the assistant_id in the URL. For example, in the URL https://app.tasking.ai/projects/pX******/assistants/X5lMJvqeJlZ6tKPu********/records, the assistant_id is X5lMJvqeJlZ6tKPu********.

note

The Python SDK is for interacting with the assistant application, not for configuring it. Please update the assistant's configuration in the online playground.