Seamlessly Migrate and Innovate: Introducing TaskingAI's OpenAI-Compatible API

May 13, 2024
Patrick Chen

Background

TaskingAI consolidates the APIs from various model providers into a unified platform. When you use TaskingAI's API to interact with models or assistants, you receive responses in a format consistent with TaskingAI, despite differences among model providers.

As many existing projects are built with OpenAI-compatible APIs and SDKs, we are happy to announce that we have created an OpenAI-compatible API. This feature makes it easier for you to migrate your projects to TaskingAI with minimal code changes.

Usage

Normal TaskingAI API calls are made to https://api.tasking.ai, and the responses adhere to TaskingAI's format. To obtain OpenAI-compatible responses, simply change the base URL to https://oapi.tasking.ai. All endpoints of the OpenAI-compatible API match those of the TaskingAI API, allowing you to use the same endpoints and parameters.

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

1from openai import OpenAI
2
3client = OpenAI(
4    api_key="YOUR_TASKINGAI_API_KEY",
5    base_url="https://oapi.tasking.ai/v1",
6)
7
8# 'model' can be either a TaskingAI model ID for direct chat completion model inference 
9# or an assistant ID for an agent invoke including sophisticated retrieval, action, and # plugin integrations.
10
11response = client.chat.completions.create(
12    model="YOUR_TASKINGAI_MODEL_ID_OR_ASSISTANT_ID",
13    messages=[
14        {"role": "user", "content": "Hello, how are you?"},
15    ]
16)
17
18print(response)

With the OpenAI-compatible API, you can utilize TaskingAI's service with almost all existing OpenAI-compatible SDKs and libraries without any changes to your code. Whether you're looking to engage directly through a specific model or require the broader capabilities of an assistant with integrated features, the flexibility is at your fingertips.

Moreover, with TaskingAI, the model can be not only from OpenAI's suite but also from hundreds of other mainstream LLMs such as Gemini, Claude, and Mistral. This vast compatibility allows you to seamlessly integrate a diverse range of powerful models into your applications, expanding your ability to innovate and enhance your solutions.

Explore Further

For more detailed documentation on the usage of the OpenAI-compatible API, please refer to our official documentation.

We encourage you to explore the new OpenAI-compatible feature and see how it can streamline your integration process. Whether you're migrating existing projects or starting new ones, this compatibility layer ensures a seamless transition and a flexible approach to using TaskingAI’s powerful capabilities. Try it out today and unlock the full potential of your applications with TaskingAI.

Previous post
No items
No items

On this page

©️ 2024 TaskingAI All Copyright Reserved