Create embeddings
Creates an embedding vector representing input text. Compatible with the OpenAI /v1/embeddings API.
Pass a single string or an array of strings. The response contains one embedding vector per input.
Example request
curl https://api.deutschlandgpt.de/v2/embeddings \
-X POST \
-H "Authorization: Bearer $DGPT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "The quick brown fox jumps over the lazy dog.",
"model": "text-embedding-3-large",
"encoding_format": "float",
"dimensions": 0,
"task_type": "SEMANTIC_SIMILARITY"
}'curl https://api.deutschlandgpt.de/v2/embeddings \
-X POST \
-H "Authorization: Bearer $DGPT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "The quick brown fox jumps over the lazy dog.",
"model": "text-embedding-3-large",
"encoding_format": "float",
"dimensions": 0,
"task_type": "SEMANTIC_SIMILARITY"
}'import os, requests
response = requests.post(
"https://api.deutschlandgpt.de/v2/embeddings",
headers={"Authorization": f"Bearer {os.environ['DGPT_API_KEY']}"},
json={
"input": "The quick brown fox jumps over the lazy dog.",
"model": "text-embedding-3-large",
"encoding_format": "float",
"dimensions": 0,
"task_type": "SEMANTIC_SIMILARITY"
},
)
print(response.json())import os, requests
response = requests.post(
"https://api.deutschlandgpt.de/v2/embeddings",
headers={"Authorization": f"Bearer {os.environ['DGPT_API_KEY']}"},
json={
"input": "The quick brown fox jumps over the lazy dog.",
"model": "text-embedding-3-large",
"encoding_format": "float",
"dimensions": 0,
"task_type": "SEMANTIC_SIMILARITY"
},
)
print(response.json())const response = await fetch('https://api.deutschlandgpt.de/v2/embeddings', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.DGPT_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"input": "The quick brown fox jumps over the lazy dog.",
"model": "text-embedding-3-large",
"encoding_format": "float",
"dimensions": 0,
"task_type": "SEMANTIC_SIMILARITY"
}),
});
console.log(await response.json());const response = await fetch('https://api.deutschlandgpt.de/v2/embeddings', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.DGPT_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"input": "The quick brown fox jumps over the lazy dog.",
"model": "text-embedding-3-large",
"encoding_format": "float",
"dimensions": 0,
"task_type": "SEMANTIC_SIMILARITY"
}),
});
console.log(await response.json());Request body
inputstring | string[]requiredText(s) to embed. Each string must be within the model's max token limit.
modelstringoptionalEmbedding model ID.
encoding_formatstringoptionalfloat returns a number array; base64 returns a base64-encoded Float32Array binary.
dimensionsintegeroptionalDesired output dimensions. Only supported by select models (e.g. text-embedding-3-large, gemini-embedding-001). Must be within the model's supported range.
task_typestringoptionalTask type hint to optimize embeddings for. Only supported by Gemini embedding models.
Response
{
"object": "list",
"data": [
{
"object": "embedding",
"embedding": [
null
],
"index": 0
}
],
"model": "string",
"usage": {
"prompt_tokens": 0,
"total_tokens": 0
}
}{
"object": "list",
"data": [
{
"object": "embedding",
"embedding": [
null
],
"index": 0
}
],
"model": "string",
"usage": {
"prompt_tokens": 0,
"total_tokens": 0
}
}Embedding response
objectstringdataobject[]objectstringembeddingnumber[] | stringindexintegerIndex of the input string this embedding corresponds to
modelstringusageobjectprompt_tokensintegertotal_tokensintegerResponse codes
Embedding response
objectUnsupported dimensions or task_type
ErrorUnauthorized
Insufficient credits
Model not found