Skip to main content

Text Embedding

Text embedding tasks take a string as input and generates a list of embeddings for the sentences.

For TaskingAI's own API, please refer to the Text Embedding API.

The OpenAI-compatible API for text embedding follows OpenAI's text embedding input schema, and output schemas.

Basic usage


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

response = client.Embedding.create(
model="YOUR_TASKINGAI_EMBEDDING_MODEL_ID",
documents=[
"Hello, how are you?",
"I am fine, thank you."
]
)

print(response)
note

Replace YOUR_TASKINGAI_EMBEDDING_MODEL_ID with your TaskingAI text embedding model ID. The embedding model does not need to be from OpenAI. All embedding models from different providers can be used with the OpenAI-compatible API.