Skip to main content
Use CometAPI embeddings when your app needs vectors for semantic search, clustering, recommendations, or retrieval. Send text to /v1/embeddings, store the returned vector, and search it with your vector database.

Create an embedding

Use an embedding-capable model ID from the Models page or the model directory. The examples below call the OpenAI-compatible Embeddings API.
These examples use the placeholder your-embedding-model-id. Replace it with an available embedding model ID from the Models page or model directory before you run the request.
Open Embeddings API reference to use the playground and endpoint schema.
import os
import requests

response = requests.post(
    "https://api.cometapi.com/v1/embeddings",
    headers={
        "Authorization": "Bearer " + os.environ["COMETAPI_KEY"],
        "Content-Type": "application/json",
    },
    json={
        "model": "your-embedding-model-id",
        "input": "CometAPI lets developers use many model providers.",
    },
    timeout=30,
)

response.raise_for_status()
result = response.json()
print(len(result["data"][0]["embedding"]))

Response example

A successful response can look like this. The response includes one vector for each input item; the vector below is shortened for readability:
{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "index": 0,
      "embedding": [
        -0.0021,
        -0.0491,
        0.0209
      ]
    }
  ],
  "model": "your-embedding-model-id",
  "usage": {
    "prompt_tokens": 10,
    "total_tokens": 10
  }
}

Batch input

Send an array of strings when you want several vectors from one request:
cURL
curl https://api.cometapi.com/v1/embeddings \
  -H "Authorization: Bearer $COMETAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "your-embedding-model-id",
    "input": [
      "Create an API key",
      "Change the base URL",
      "Retry after a rate limit"
    ]
  }'

Example model records

This example model catalog response shows the /api/models envelope and one OpenAI-compatible embedding model record shape. Some embedding records use an empty model_type; choose an embedding model by ID and endpoint support instead of relying on that field alone.
cURL
curl https://api.cometapi.com/api/models
{
  "success": true,
  "page": 1,
  "page_size": 20,
  "total": 302,
  "data": [
    {
      "created": 1757904564,
      "id": "your-embedding-model-id",
      "code": "your-embedding-model-id",
      "provider": "ExampleProvider",
      "provider_code": "example",
      "name": "Example embedding model",
      "model_type": "embedding",
      "features": [
        "text-embedding"
      ],
      "endpoints": [
        "openai"
      ],
      "pricing": {
        "currency": "USD / M Tokens",
        "input": 0.1,
        "output": null,
        "per_request": null,
        "per_second": null
      }
    }
  ]
}

Common errors

Split long documents into chunks before embedding.
Choose an embedding-capable model from the model directory.
Keep the same model and dimensions for one vector index.
Send Authorization: Bearer $COMETAPI_KEY.

Error codes and retry strategy

Do not retry until the input, model ID, or dimensions setting is fixed.
Do not retry until the API key is present and valid.
Check the base URL, path, and model ID before retrying.
Retry with exponential backoff and reduce batch size or concurrency.
Retry with backoff for transient provider or service errors.
For implementation patterns, see Error codes and retry strategy and Rate limits and concurrency.

Pricing and model directory

Models page

Read how CometAPI exposes model IDs in the docs.

Model directory

Browse model availability and capabilities.

Pricing

Check pricing before you call a model.
Last modified on May 28, 2026