> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pixeltable.com/llms.txt
> Use this file to discover all available pages before exploring further.

# nebius

> <a href="https://github.com/pixeltable/pixeltable/blob/main/pixeltable/functions/nebius.py#L0" id="viewSource" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/badge/View%20Source%20on%20Github-blue?logo=github&labelColor=gray" alt="View Source on GitHub" style={{ display: 'inline', margin: '0px' }} noZoom /></a>

# <span style={{ 'color': 'gray' }}>module</span>  pixeltable.functions.nebius

Pixeltable UDFs for Nebius Token Factory models.

Provides integration with Nebius Token Factory's language and embedding models. In order to use
them, you must first `pip install openai` and configure your Nebius Token Factory API key, by
setting the `NEBIUS_API_KEY` environment variable or `nebius.api_key` in the Pixeltable config file.

## <span style={{ 'color': 'gray' }}>udf</span>  chat\_completions()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
chat_completions(
    messages: pxt.Json[(Json, ...)],
    *,
    model: pxt.String,
    model_kwargs: pxt.Json | None = None,
    tools: pxt.Json[(Json, ...)] | None = None,
    tool_choice: pxt.Json | None = None
) -> pxt.Json
```

Creates a model response for the given chat conversation.

Equivalent to the Nebius Token Factory `chat/completions` API endpoint.
For additional details, see: [https://docs.tokenfactory.nebius.com/api-reference/inference/create-chat-completion](https://docs.tokenfactory.nebius.com/api-reference/inference/create-chat-completion)

Nebius Token Factory exposes an OpenAI-compatible API, so you will need to install the
`openai` package to use this UDF.

Request throttling:
Applies the rate limit set in the config (section `nebius`, key `rate_limit`). If no rate
limit is configured, a default rate limit is applied.

**Requirements:**

* `pip install openai`

**Parameters:**

* **`messages`** (`pxt.Json[(Json`): A list of messages to use for chat completion, as described in the Nebius API documentation.
* **`model`** (`Any`): The model to use for chat completion.
* **`model_kwargs`** (`Any`): Additional keyword args for the Nebius `chat/completions` API.
  For details on the available parameters, see: [https://docs.tokenfactory.nebius.com/api-reference/inference/create-chat-completion](https://docs.tokenfactory.nebius.com/api-reference/inference/create-chat-completion)
* **`tools`** (`Any`): An optional list of Pixeltable tools to use for the request.
* **`tool_choice`** (`Any`): An optional tool choice configuration.

**Returns:**

* `pxt.Json`: A dictionary containing the response and other metadata.

**Examples:**

Add a computed column that applies the model `meta-llama/Llama-3.3-70B-Instruct`
to an existing Pixeltable column `tbl.prompt` of the table `tbl`:

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
messages = [
    {'role': 'system', 'content': 'You are a helpful assistant.'},
    {'role': 'user', 'content': tbl.prompt},
]
tbl.add_computed_column(
    response=chat_completions(
        messages, model='meta-llama/Llama-3.3-70B-Instruct'
    )
)
```

You can also include images in the messages list, for vision-capable models such as
`Qwen/Qwen2.5-VL-72B-Instruct`, by passing image data directly in the input dictionary, in
the `'image_url'` field of the message content, as in this example:

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
messages = [
    {
        'role': 'user',
        'content': [
            {'type': 'text', 'text': "What's in this image?"},
            {'type': 'image_url', 'image_url': tbl.image},
        ],
    }
]
tbl.add_computed_column(
    response=chat_completions(
        messages, model='Qwen/Qwen2.5-VL-72B-Instruct'
    )
)
```

## <span style={{ 'color': 'gray' }}>udf</span>  embeddings()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
embeddings(
    input: pxt.String,
    *,
    model: pxt.String,
    model_kwargs: pxt.Json | None = None
) -> pxt.Array[(None,), float32]
```

Query an embedding model for a given string of text.

Equivalent to the Nebius Token Factory `embeddings` API endpoint.
For additional details, see: [https://docs.tokenfactory.nebius.com/api-reference/inference/create-embeddings](https://docs.tokenfactory.nebius.com/api-reference/inference/create-embeddings)

Request throttling:
Applies the rate limit set in the config (section `nebius`, key `rate_limit`). If no rate
limit is configured, a default rate limit is applied.

**Requirements:**

* `pip install openai`

**Parameters:**

* **`input`** (`pxt.String`): A string providing the text for the model to embed.
* **`model`** (`pxt.String`): The name of the embedding model to use.
* **`model_kwargs`** (`pxt.Json | None`): Additional keyword args for the Nebius `embeddings` API, e.g. `dimensions` to
  request a truncated embedding for models that support it (see the note below).

**Returns:**

* `pxt.Array[(None,), float32]`: An array representing the application of the given embedding to `input`.

**Examples:**

Add a computed column that applies the model `Qwen/Qwen3-Embedding-8B`
to an existing Pixeltable column `tbl.text` of the table `tbl`:

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
tbl.add_computed_column(
    response=embeddings(tbl.text, model='Qwen/Qwen3-Embedding-8B')
)
```

`Qwen/Qwen3-Embedding-8B` produces 4096-dimensional embeddings by default, which exceed
the maximum of 4000 dimensions supported by Pixeltable embedding indexes. Request a
smaller, indexable size via `model_kwargs`:

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
tbl.add_embedding_index(
    'text',
    embedding=embeddings.using(
        model='Qwen/Qwen3-Embedding-8B', model_kwargs={'dimensions': 1024}
    ),
)
```
