Skip to main content

Overview

Background

TaskingAI brings together the APIs from many different model providers into one unified platform. When you use TaskingAI's API to interact with models or assistants, you get responses in a consistent format defined by TaskingAI even if the model providers differ from each other.

However, as there are many existing projects built with OpenAI's API or OpenAI-compatible APIs, we have created an OpenAI-compatible API to make it easier for you to migrate your projects to TaskingAI with minimum changes in code.

How to Use

Normal TaskingAI API calls are made to https://api.tasking.ai/, and the response will be of TaskingAI's format. To get OpenAI-compatible responses, all you need to do is change the base URL to https://oapi.tasking.ai/.

All endpoints of the OpenAI-compatible API are the same as the TaskingAI API. You can use the same endpoints and parameters as you would with the TaskingAI API.

Example

Here is an example of how to use the OpenAI python SDK to interact with TaskingAI's service through the OpenAI-compatible API:

from openai import OpenAI

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

# If you prefer to directly interact with your TaskingAI models, replace with your model ID.
MODEL_ID = "YOUR_TASKINGAI_ASSISTANT_ID"

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

print(response)

With the OpenAI-compatible API, you may utilize TaskingAI's service with almost all existing OpenAI-compatible SDKs and libraries without any changes in your code.