Skip to content

text-embedding-3-small

POSThttps://gptunnel.ru/v1/embeddings

The endpoint returns a numeric vector for the input text. Without dimensions, text-embedding-3-small returns 1536 numbers.

Request headers

ParameterTypeRequired?Description
AuthorizationstringRequiredGPTunneL API key

Request body

ParameterTypeRequired?Description
model#stringRequiredModel ID: text-embedding-3-small
input#stringRequiredText to embed. Send a non-empty string
dimensions#integerOptionalNumber of elements in the vector. Default: 1536. This example uses 1024
useWalletBalance#booleanOptionalSet to true to use your personal balance

Set your API key in the GPTUNNEL_API_KEY environment variable.

import json
import os
from urllib.request import Request, urlopen
body = {
'model': 'text-embedding-3-small',
'input': 'A blue sky.',
'dimensions': 1024,
}
request = Request(
'https://gptunnel.ru/v1/embeddings',
headers={
'Authorization': os.environ['GPTUNNEL_API_KEY'],
'Content-Type': 'application/json',
},
data=json.dumps(body).encode('utf-8'),
method='POST',
)
with urlopen(request, timeout=30) as response:
print(json.load(response))

This request returns 1024 numbers in data[0].embedding. The example shows the first three. usage.prompt_tokens gives the input token count, and usage.total_cost gives the request cost in rubles. This response omits usage.total_tokens.

{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [
0.0264739990234375,
0.00055694580078125,
-0.01197052001953125
]
}
],
"model": "text-embedding-3-small",
"usage": {
"prompt_tokens": 4,
"completion_tokens": 0,
"prompt_cost": 8e-05,
"completion_cost": 0,
"total_cost": 8e-05
}
}
HTTP What to check
400 If the response says model is required, include model in the request body.
401 Send a valid API key in the Authorization header.
402 Check the balance of the selected account.
404 For invalid_model_error, check the model ID against the catalog for your key.
422 For invalid_input with error.param: "input", send non-empty text in input.

The endpoint returns this response if you omit input or send an empty string.

{
"error": {
"message": "input must be not empty",
"type": "invalid_input",
"param": "input",
"code": null
}
}