# text-embedding-3-large

{% hint style="info" %}
Чтобы отправлять авторизованные запросы нужно получить API ключ, как это сделать написано в разделе [**С чего начать?**](https://docs.gptunnel.ru/)
{% endhint %}

## Создание векторов

<mark style="color:green;">`POST`</mark> `https://gptunnel.ru/v1/embeddings`

Синхронный запрос к модели text-embedding-3-large

#### Headers

| Name                                            | Type   | Description |
| ----------------------------------------------- | ------ | ----------- |
| Authorization<mark style="color:red;">\*</mark> | string | API ключ    |

#### Request Body

| Name                                    | Type   | Description              |
| --------------------------------------- | ------ | ------------------------ |
| model<mark style="color:red;">\*</mark> | string | ID модели                |
| input<mark style="color:red;">\*</mark> | string | Контент                  |
| useWalletBalance                        | bool   | Использовать личный счет |
| dimensions                              | number | Кол-во измерений         |

{% tabs %}
{% tab title="200: OK Успешный ответ" %}
{% code fullWidth="false" %}

```
{
	"object": "list",
	"data": [
		{
			"object": "embedding",
			"index": 0,
			"embedding": [
				-0.007021796,
				"A LOT OF NUMBERS",
				-0.017013576,
				-0.000082575396,
				-0.023988336
			]
		}
	],
	"model": "text-embedding-3-large",
	"usage": {
		"prompt_tokens": 5,
		"total_tokens": 5,
		"prompt_cost": 0.00045,
		"completion_cost": 0,
		"total_cost": 0.00045
	}
}
```

{% endcode %}
{% endtab %}

{% tab title="404: Not Found Модель не найдена" %}

```json
{
  "error": {
    "message": "The model 'gpt-5' does not exist",
    "type": "invalid_request_error",
    "param": null,
    "code": "model_not_found"
  }
}
```

{% endtab %}

{% tab title="Untitled" %}

{% endtab %}

{% tab title="400: Bad Request Неверный запрос" %}

```json
{
  "error": {
    "message": "'model' is a required property",
    "type": "invalid_request_error",
    "param": null,
    "code": null
  }
}
```

{% endtab %}

{% tab title="402: Payment Required Недостаточно средств" %}

```json
{
  "error": {
    "message": "Organization balance is too low to use API",
    "type": "insufficient_balance_error",
    "param": null,
    "code": null
  }
}
```

{% endtab %}

{% tab title="401: Unauthorized Ошибка авторизации" %}

```json
{
  "error": {
    "message": "Unauthorized",
    "type": "unauthorized_request_error",
    "param": null,
    "code": null,
  }
}
```

{% endtab %}
{% endtabs %}

### Пример запроса

{% tabs %}
{% tab title="NodeJS" %}

```typescript
import axios from 'axios'

const request = axios({
  method: 'POST',
  url: 'https://gptunnel.ru/v1/embeddings',
  headers: {
    // use your API key here
    Authorization: 'YOUR_API_KEY',
  },
  data: {
     model: "text-embedding-3-large",
     input: "Your text string goes here",
     dimensions: 2048,
  },
})

request.then((result) => {
  console.log(result)
}).catch((error) => {
  console.error(error)
})
```

{% endtab %}

{% tab title="Curl" %}

```bash
curl --request POST \
  --url https://gptunnel.ru/v1/embeddings \
  --header 'Authorization: YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
      "model": "text-embedding-3-large",
      "input": "Your text string goes here",
      "dimensions": 2048,
}'
```

{% endtab %}
{% endtabs %}

### Пример ответа

```json
{
	"object": "list",
	"data": [
		{
			"object": "embedding",
			"index": 0,
			"embedding": [
				-0.007021796,
				"A LOT OF NUMBERS",
				-0.017013576,
				-0.000082575396,
				-0.023988336
			]
		}
	],
	"model": "text-embedding-3-small",
	"usage": {
		"prompt_tokens": 5,
		"total_tokens": 5,
		"prompt_cost": 0.00045,
		"completion_cost": 0,
		"total_cost": 0.00045
	}
}
```
