Skip to main content
POST
/
embeddings
Python
from opperai import Opper

opper = Opper(http_bearer="YOUR_API_KEY")

# Create embedding for a single text
single_embedding = opper.embeddings.create(
    input="The quick brown fox jumps over the lazy dog",
    model="azure/text-embedding-3-large",
)

print(f"Model: {single_embedding.model}")
print(f"Embedding dimensions: {len(single_embedding.data[0]['embedding'])}")
print(f"Usage: {single_embedding.usage}")

# Create embeddings for multiple texts
multiple_embeddings = opper.embeddings.create(
    input=[
        "What is machine learning?",
        "How do neural networks work?",
        "Explain artificial intelligence",
    ]
)

print(f"\nCreated {len(multiple_embeddings.data)} embeddings")
for i, embedding_data in enumerate(multiple_embeddings.data):
    print(f"Embedding {i}: {len(embedding_data['embedding'])} dimensions")
{
  "model": "<string>",
  "data": [
    {}
  ],
  "usage": {}
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
input
required

The input to embed, can be a single string or a list of strings

Example:

"Hello, world!"

model

The model to use for the embedding, if not provided, EmbeddingModel(hosting_provider='Azure', location='EU', identifier='azure/text-embedding-3-large', name='azure/text-embedding-3-large-1536', dimensions=1536, max_tokens=8191, credentials='azure-se', is_default=True, is_public=True, extra={'api_base': 'https://opperopenaiservice.openai.azure.com', 'api_version': '2023-05-15', 'dimensions': 1536}) will be used

Example:
{
"extra_headers": {},
"name": "text-embedding-3-large",
"options": { "dimensions": 256 }
}

Response

Successful Response

model
string
required

The model that was used to create the embedding

data
Data · object[]
required

The embedding data

usage
Usage · object
required

The usage information