Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
195 commits
Select commit Hold shift + click to select a range
afb4d92
privileges.md French
arnaud4d Nov 4, 2026
b363d2c
quotas.md French
arnaud4d Nov 4, 2026
a8958e8
dataclassclass.md French
arnaud4d Nov 4, 2026
00aa1b2
write-class-method.md French
arnaud4d Nov 4, 2026
e02c06c
privileges.md Spanish
arnaud4d Nov 4, 2026
5d56872
quotas.md Spanish
arnaud4d Nov 4, 2026
1eb7e8e
exit.md Spanish
arnaud4d Nov 4, 2026
2f06e17
buttongrid_overview.md Japanese
arnaud4d Nov 4, 2026
01c499c
button_overview.md Japanese
arnaud4d Nov 4, 2026
43633ae
checkbox_overview.md Japanese
arnaud4d Nov 4, 2026
069cf85
dropdownlist_overview.md Japanese
arnaud4d Nov 4, 2026
3bc7aa5
list_overview.md Japanese
arnaud4d Nov 4, 2026
75d0572
listbox-object.md Japanese
arnaud4d Nov 4, 2026
11e479a
picturebutton_overview.md Japanese
arnaud4d Nov 4, 2026
918645c
picturepopupmenu_overview.md Japanese
arnaud4d Nov 4, 2026
5a051a5
pluginarea_overview.md Japanese
arnaud4d Nov 4, 2026
29fa1ae
progressindicator.md Japanese
arnaud4d Nov 4, 2026
538ad66
properties_backgroundandborder.md Japanese
arnaud4d Nov 4, 2026
4be61b3
radio_overview.md Japanese
arnaud4d Nov 4, 2026
0659b45
tabcontrol.md Japanese
arnaud4d Nov 4, 2026
968ecf0
privileges.md Japanese
arnaud4d Nov 4, 2026
9bcc138
quotas.md Japanese
arnaud4d Nov 4, 2026
afbb8c5
radio_overview.md Japanese
arnaud4d Nov 4, 2026
fbef9f4
privileges.md Japanese
arnaud4d Nov 4, 2026
a480e99
quotamanagerclass.md French
arnaud4d Nov 5, 2026
c72ab20
quotamanagerclass.md Spanish
arnaud4d Nov 5, 2026
0f22ab2
menu.png French
arnaud4d Nov 5, 2026
6365f36
studio-interface.png French
arnaud4d Nov 5, 2026
eba5f07
definition.md French
arnaud4d Nov 5, 2026
c0922b0
embedder.md French
arnaud4d Nov 5, 2026
87ee5be
embedderresult.md French
arnaud4d Nov 5, 2026
73ee234
phrase.md French
arnaud4d Nov 5, 2026
fa2867e
process.md French
arnaud4d Nov 5, 2026
b359567
processerror.md French
arnaud4d Nov 5, 2026
52cdb3d
processerrorcode.md French
arnaud4d Nov 5, 2026
c3e4554
processresult.md French
arnaud4d Nov 5, 2026
a3ecf68
scheduler.md French
arnaud4d Nov 5, 2026
fe64c1c
settings.md French
arnaud4d Nov 5, 2026
0b12a57
studioembedder.md French
arnaud4d Nov 5, 2026
adc0308
license.md French
arnaud4d Nov 5, 2026
1f471bc
overview.md French
arnaud4d Nov 5, 2026
f494508
ratelimit.md French
arnaud4d Nov 5, 2026
77d7e47
menu.png French
arnaud4d Nov 5, 2026
c890fc2
studio-interface.png French
arnaud4d Nov 5, 2026
ffb567e
definition.md French
arnaud4d Nov 5, 2026
2f84a65
embedder.md French
arnaud4d Nov 5, 2026
52d9c4a
embedderresult.md French
arnaud4d Nov 5, 2026
02d0cf7
phrase.md French
arnaud4d Nov 5, 2026
7345b78
process.md French
arnaud4d Nov 5, 2026
f822b53
processerror.md French
arnaud4d Nov 5, 2026
3a1eca5
processerrorcode.md French
arnaud4d Nov 5, 2026
00dfa83
processresult.md French
arnaud4d Nov 5, 2026
9c763db
scheduler.md French
arnaud4d Nov 5, 2026
4f2e669
settings.md French
arnaud4d Nov 5, 2026
37be669
studioembedder.md French
arnaud4d Nov 5, 2026
827c73a
license.md French
arnaud4d Nov 5, 2026
827d3c6
overview.md French
arnaud4d Nov 5, 2026
eeafbe3
ratelimit.md French
arnaud4d Nov 5, 2026
9ea6ba9
menu.png Spanish
arnaud4d Nov 5, 2026
fdbb0f9
studio-interface.png Spanish
arnaud4d Nov 5, 2026
7b0eb9f
definition.md Spanish
arnaud4d Nov 5, 2026
28d00f4
embedder.md Spanish
arnaud4d Nov 5, 2026
dc00ba9
embedderresult.md Spanish
arnaud4d Nov 5, 2026
8e95c8c
phrase.md Spanish
arnaud4d Nov 5, 2026
518a843
process.md Spanish
arnaud4d Nov 5, 2026
335ebf0
processerror.md Spanish
arnaud4d Nov 5, 2026
6f77c2b
processerrorcode.md Spanish
arnaud4d Nov 5, 2026
1ed6732
processresult.md Spanish
arnaud4d Nov 5, 2026
8dd6745
scheduler.md Spanish
arnaud4d Nov 5, 2026
0e86c78
settings.md Spanish
arnaud4d Nov 5, 2026
7bb6b3e
studioembedder.md Spanish
arnaud4d Nov 5, 2026
7669d42
license.md Spanish
arnaud4d Nov 5, 2026
a46cb41
overview.md Spanish
arnaud4d Nov 5, 2026
229a975
ratelimit.md Spanish
arnaud4d Nov 5, 2026
3a82abd
menu.png Spanish
arnaud4d Nov 5, 2026
e8c64a0
studio-interface.png Spanish
arnaud4d Nov 5, 2026
334c5de
definition.md Spanish
arnaud4d Nov 5, 2026
e2bc87a
embedder.md Spanish
arnaud4d Nov 5, 2026
89dfaab
embedderresult.md Spanish
arnaud4d Nov 5, 2026
d33c232
phrase.md Spanish
arnaud4d Nov 5, 2026
f485e0d
process.md Spanish
arnaud4d Nov 5, 2026
8806b3e
processerror.md Spanish
arnaud4d Nov 5, 2026
79c1c11
processerrorcode.md Spanish
arnaud4d Nov 5, 2026
9ebc5d0
processresult.md Spanish
arnaud4d Nov 5, 2026
6c9f06e
scheduler.md Spanish
arnaud4d Nov 5, 2026
73dc1a3
settings.md Spanish
arnaud4d Nov 5, 2026
ddb22cd
studioembedder.md Spanish
arnaud4d Nov 5, 2026
d1ab8d3
license.md Spanish
arnaud4d Nov 5, 2026
4c32fd2
overview.md Spanish
arnaud4d Nov 5, 2026
c9828ca
ratelimit.md Spanish
arnaud4d Nov 5, 2026
0a75574
menu.png Japanese
arnaud4d Nov 5, 2026
71afde8
studio-interface.png Japanese
arnaud4d Nov 5, 2026
f5cde3d
definition.md Japanese
arnaud4d Nov 5, 2026
73a1822
embedder.md Japanese
arnaud4d Nov 5, 2026
b99792e
embedderresult.md Japanese
arnaud4d Nov 5, 2026
facf38d
phrase.md Japanese
arnaud4d Nov 5, 2026
fba1c9e
process.md Japanese
arnaud4d Nov 5, 2026
bef5bd8
processerror.md Japanese
arnaud4d Nov 5, 2026
96e6efa
processerrorcode.md Japanese
arnaud4d Nov 5, 2026
8d92a01
processresult.md Japanese
arnaud4d Nov 5, 2026
53cb6de
scheduler.md Japanese
arnaud4d Nov 5, 2026
81ad4fd
settings.md Japanese
arnaud4d Nov 5, 2026
8155574
studioembedder.md Japanese
arnaud4d Nov 5, 2026
adde6d5
license.md Japanese
arnaud4d Nov 5, 2026
325c240
overview.md Japanese
arnaud4d Nov 5, 2026
4c37c50
ratelimit.md Japanese
arnaud4d Nov 5, 2026
18d388b
menu.png Japanese
arnaud4d Nov 5, 2026
b433903
studio-interface.png Japanese
arnaud4d Nov 5, 2026
cf2bf86
definition.md Japanese
arnaud4d Nov 5, 2026
57fa83f
embedder.md Japanese
arnaud4d Nov 5, 2026
fa03a44
embedderresult.md Japanese
arnaud4d Nov 5, 2026
614dbc2
phrase.md Japanese
arnaud4d Nov 5, 2026
0ba09d7
process.md Japanese
arnaud4d Nov 5, 2026
6cf42ab
processerror.md Japanese
arnaud4d Nov 5, 2026
ca1d3d1
processerrorcode.md Japanese
arnaud4d Nov 5, 2026
49a51bb
processresult.md Japanese
arnaud4d Nov 5, 2026
45c0cc3
scheduler.md Japanese
arnaud4d Nov 5, 2026
cbe2ef2
settings.md Japanese
arnaud4d Nov 5, 2026
565a85f
studioembedder.md Japanese
arnaud4d Nov 5, 2026
9e5e483
license.md Japanese
arnaud4d Nov 5, 2026
0a68bf7
overview.md Japanese
arnaud4d Nov 5, 2026
51c1eb6
ratelimit.md Japanese
arnaud4d Nov 5, 2026
116333e
dataclassclass.md French
arnaud4d Nov 5, 2026
5bf1d28
udpsocketclass.md Japanese
arnaud4d Nov 5, 2026
c23d163
websocketserverclass.md Japanese
arnaud4d Nov 5, 2026
2815344
methods.md Japanese
arnaud4d Nov 5, 2026
a3de538
labels.md Japanese
arnaud4d Nov 5, 2026
70875ad
preemptive.md French
arnaud4d Nov 5, 2026
83cb9ec
preemptive.md Spanish
arnaud4d Nov 5, 2026
31faae8
preemptive.md Japanese
arnaud4d Nov 5, 2026
58419be
processes.md Japanese
arnaud4d Nov 5, 2026
d77f0a0
createstylesheet.md Japanese
arnaud4d Nov 5, 2026
3c06c58
properties_backgroundandborder.md Japanese
arnaud4d Nov 5, 2026
301a217
properties_datasource.md Japanese
arnaud4d Nov 5, 2026
9915704
privileges.md French
arnaud4d Nov 5, 2026
95e973a
privileges.md Spanish
arnaud4d Nov 5, 2026
f826f66
privileges.md Japanese
arnaud4d Nov 5, 2026
217fc91
client-server.md French
arnaud4d Nov 5, 2026
f209276
collectionclass.md French
arnaud4d Nov 5, 2026
d2b3f48
dt_number.md French
arnaud4d Nov 5, 2026
54b10d3
dt_number.md Spanish
arnaud4d Nov 5, 2026
ea1bc83
dt_number.md Japanese
arnaud4d Nov 5, 2026
a09fd5c
createstylesheet.md Japanese
arnaud4d Nov 5, 2026
75dbe44
labels.md Japanese
arnaud4d Nov 5, 2026
aad27d5
preemptive.md French
arnaud4d Nov 5, 2026
70981c9
preemptive.md Spanish
arnaud4d Nov 5, 2026
0f211ec
preemptive.md Japanese
arnaud4d Nov 5, 2026
dbde6a9
processes.md Japanese
arnaud4d Nov 5, 2026
7d7fa97
createstylesheet.md Japanese
arnaud4d Nov 5, 2026
e1404dd
collectionclass.md Spanish
arnaud4d Nov 5, 2026
e75192b
cryptokeyclass.md French
arnaud4d Nov 5, 2026
cb53f52
cryptokeyclass.md Spanish
arnaud4d Nov 5, 2026
74f5164
dataclassclass.md French
arnaud4d Nov 5, 2026
b6049b3
datastoreclass.md French
arnaud4d Nov 5, 2026
fd174d3
datastoreclass.md Spanish
arnaud4d Nov 5, 2026
3a31741
entityclass.md French
arnaud4d Nov 5, 2026
d9bddcd
httprequestclass.md French
arnaud4d Nov 5, 2026
3b76db5
imaptransporterclass.md French
arnaud4d Nov 5, 2026
2f9efd6
udpsocketclass.md Japanese
arnaud4d Nov 5, 2026
2d63543
websocketserverclass.md Japanese
arnaud4d Nov 5, 2026
ab86f3f
labels.md Japanese
arnaud4d Nov 5, 2026
439ad00
preemptive.md French
arnaud4d Nov 5, 2026
7d10389
preemptive.md Spanish
arnaud4d Nov 5, 2026
6c9853b
preemptive.md Japanese
arnaud4d Nov 5, 2026
1fccfcb
processes.md Japanese
arnaud4d Nov 5, 2026
a5095af
structure-indexes.md French
arnaud4d Nov 5, 2026
f3d3ea5
structure-indexes.md Spanish
arnaud4d Nov 5, 2026
75140ea
structure-indexes.md Japanese
arnaud4d Nov 5, 2026
e65c1d6
createstylesheet.md Japanese
arnaud4d Nov 5, 2026
06f8388
button_overview.md Japanese
arnaud4d Nov 5, 2026
a9eb603
checkbox_overview.md Japanese
arnaud4d Nov 5, 2026
1af0ceb
properties_backgroundandborder.md Japanese
arnaud4d Nov 5, 2026
71b4478
properties_datasource.md Japanese
arnaud4d Nov 5, 2026
eaf1d6b
privileges.md French
arnaud4d Nov 5, 2026
8ee7997
privileges.md Spanish
arnaud4d Nov 5, 2026
814b633
write-class-method.md Spanish
arnaud4d Nov 5, 2026
ca61c0a
exit.md Japanese
arnaud4d Nov 5, 2026
6044170
client-server.md Japanese
arnaud4d Nov 5, 2026
9ad360b
udpsocketclass.md Japanese
arnaud4d Nov 5, 2026
6311553
websocketserverclass.md Japanese
arnaud4d Nov 5, 2026
fae40b7
labels.md Japanese
arnaud4d Nov 5, 2026
b3776dd
preemptive.md French
arnaud4d Nov 5, 2026
b71eedc
preemptive.md Spanish
arnaud4d Nov 5, 2026
0ad9b3d
preemptive.md Japanese
arnaud4d Nov 5, 2026
f68aafd
processes.md Japanese
arnaud4d Nov 5, 2026
ffe2a0b
createstylesheet.md Japanese
arnaud4d Nov 5, 2026
41e8d43
definition.md French
arnaud4d Nov 5, 2026
c86c03f
definition.md Spanish
arnaud4d Nov 5, 2026
8a46f90
definition.md Japanese
arnaud4d Nov 5, 2026
fad35f6
scheduler.md French
arnaud4d Nov 5, 2026
b1eca2b
scheduler.md Spanish
arnaud4d Nov 5, 2026
c506256
scheduler.md Japanese
arnaud4d Nov 5, 2026
5d63714
index-add.png French
arnaud4d Nov 5, 2026
bcd8e73
index-add.png Spanish
arnaud4d Nov 5, 2026
757f372
index-add.png Japanese
arnaud4d Nov 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ La clase `4D.QuotaManager` le ofrece una interfaz para configurar y monitorizar

:::

:::tip Entradas de blog relacionadas

[Un servidor web 4D que sabe cuándo decir No](https://blog.4d.com/a-4d-web-server-that-knows-when-to-say-no/)

:::

Los objetos `4D.QuotaManager` se pueden instanciar de las siguientes maneras:

- la [propiedad `quotas` de un objeto Session](./SessionClass.md#quotas)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Dado que un hilo se maneja de forma independiente a partir del método del proce

La propiedad "seguridad de hilo" de cada elemento depende del elemento en sí:

- Comandos 4D: hilo seguro es una propiedad interna. En la documentación de 4D, los comandos hilo seguro se identifican con el icono ![](../assets/en/Develop/thread-safe.png). También puede utilizar el comando [`Nombre del comando`](../commands/command-name) para saber si un comando es hilo seguro. Gran parte de los comandos 4D pueden ejecutarse en modo apropiativo.
- Comandos 4D: hilo seguro es una propiedad interna. The 4D documentation indicates whether each command is thread-safe or not in the Properties section. También puede utilizar el comando [`Nombre del comando`](../commands/command-name) para saber si un comando es hilo seguro. Gran parte de los comandos 4D pueden ejecutarse en modo apropiativo.
- Métodos de proyecto: las condiciones para seguridad de hilo se listan en [este párrafo](#writing-a-thread-safe-method).

Básicamente, el código que se ejecuta en hilos apropiativos no puede llamar a las partes con las interacciones externas, tal como el código plug-in o las variables interproceso. Los accesos a los datos, sin embargo, son permitidos desde el servidor de datos 4D que soporta la ejecución apropiativa.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,12 @@ The project's web security settings are defined in `roles.json`:

:::

:::warning

When a permission entry references an undeclared [privilege](#privileges-and-roles), 4D logs an error and ignores the entry. In this case, the permission is ignored. If the [restricted mode by default](#restriction-modes) is not enabled, the resource is accessible to `guest` sessions.

:::

### Default location and content

New projects generate `roles.json` at:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ Las cuotas del servidor web le permiten controlar el uso de recursos limitando e

:::

:::tip Entradas de blog relacionadas

[Un servidor web 4D que sabe cuándo decir No](https://blog.4d.com/a-4d-web-server-that-knows-when-to-say-no/)

:::

## Requisitos

La configuración de cuotas requiere la activación de las [sesiones escalables](./sessions.md#enabling-web-sessions).
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
---
id: definición
title: Definición
---

# Definición

The `Definition` class describes how a single vector field on a dataclass should be computed: which dataclass, which vector field, which model alias, and which text template ([Phrase](Phrase.md)) to render from each entity.

A collection of these is what [Settings](Settings.md) persists.

## Propiedades

| Nombre de la propiedad | Tipo | Descripción |
| ---------------------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| `dataclassName` | Text | Name of the target dataclass. |
| `vectorName` | Text | Name of the `4D.Vector` field on that dataclass. |
| `modelAlias` | Text | Embedding model alias (e.g. `"text-embedding-3-small"`). |
| `phrase` | [Phrase](Phrase.md) | Compiled template used to build the text that will be embedded. |
| `autoInvalidate` | Boolean | Controls automatic invalidation on entity save. Default: `True`. |

## Class constructor

Create a definition.

| Nombre del argumento | Tipo | Descripción |
| -------------------- | ---- | -------------------------------------------------------------------------------------------------- |
| *dataclassName* | Text | Name of the target dataclass. |
| *vectorName* | Text | Name of the target vector field. |
| *modelAlias* | Text | Embedding model alias. |
| *phraseTemplate* | Text | Phrase template with `{field}` placeholders — compiled into a [Phrase](Phrase.md). |

```4d
var $def:=cs.EmbeddingStudio.Definition.new(\
"Students"; \
"student_vector_1"; \
"text-embedding-3-small"; \
"Student {firstName} {lastName}")
```

## Propiedades calculadas

### hasDefinition

**hasDefinition** : Boolean *(read-only)*

Returns `True` if at least a model or a phrase template has been set. A definition without either has no content to process.

```4d
If ($def.hasDefinition)
// worth validating further
End if
```

## Funciones

### validate()

**validate**( *settings* : Settings ) : Object

Validates the definition against the live datastore model and the known embedding models. All errors are collected before returning — the result always describes the full set of problems found.

| Argumento | Tipo | Descripción |
| ---------- | ------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| *settings* | [Settings](Settings.md) \| Null | Used to pass phrase validation options. Pass `Null` to skip phrase options. |
| Resultado | Object | `{success: Boolean, errors: Collection}` where each error is `{field: Text, message: Text}`. |

Checked in order:

| Check | `field` value |
| ------------------------------------ | ----------------- |
| `dataclassName` is not empty | `"dataclassName"` |
| `vectorName` is not empty | `"vectorName"` |
| `modelAlias` is set and recognised | `"modelAlias"` |
| Dataclass exists in `ds` | `"dataclassName"` |
| Vector field exists | `"vectorName"` |
| Field type is `4D.Vector` | `"vectorName"` |
| Phrase template is not empty | `"phrase"` |
| Phrase keys resolve in the dataclass | `"phrase"` |

The first two checks (identity) return immediately on failure; the remaining checks accumulate so all problems are reported in one pass.

```4d
var $result:=$def.validate(cs.EmbeddingStudio.Settings.new())

If (Not($result.success))
var $err : Object
For each ($err; $result.errors)
TRACE // $err.field, $err.message
End for each
End if
```

### invalidateVectors()

**invalidateVectors**() : Object

Marks all already-computed entities for re-embedding, forcing a full rebuild on the next run. Only entities that already have a vector value are processed — entities with a `Null` vector are skipped.

Useful during development or after a model/phrase change to trigger a clean rebuild of all vectors.

The strategy depends on whether a companion `_dirty` field exists on the dataclass:

| Companion `_dirty` field | Action taken |
| ------------------------ | -------------------------------------------------------------- |
| Present | Sets `<vectorName>_dirty` to `True` — vector is left untouched |
| Absent | Nullifies the vector field |

| Argumento | Tipo | Descripción |
| --------- | ------ | ------------------------------------------------------------------ |
| Resultado | Object | `{updated: Integer, skipped: Integer, errors: Collection of Text}` |

- `updated` — number of entities successfully marked
- `skipped` — number of entities that could not be saved
- `errors` — one entry per save failure, formatted as `"DataclassName: statusText"`

```4d
var $result:=$def.invalidateVectors()

If ($result.skipped > 0)
var $e : Text
For each ($e; $result.errors)
// $e
End for each
End if
// → { updated: 42; skipped: 0; errors: [] }
```

### toObject()

**toObject**() : Object

Returns a plain object suitable for JSON persistence. The phrase is flattened to its template text.

| Argumento | Tipo | Descripción |
| --------- | ------ | --------------------------------------------------------------------------------------------------------------------------------- |
| Resultado | Object | `{version, dataclassName, vectorName, modelAlias, phrase, autoInvalidate}` where `phrase` is the template string. |

```4d
$def.toObject()
// → { version: 0; dataclassName: "Students"; vectorName: "student_vector_1";
// modelAlias: "text-embedding-3-small"; phrase: "Student {firstName} {lastName}";
// autoInvalidate: true }
```

## Automatic invalidation

`autoInvalidate` controls whether save-time automatic invalidation is enabled for this definition.

- `True` (default): when relevant attributes change on an entity save, vectors are automatically invalidated.
- `False`: save-time automatic invalidation is skipped for this definition.

This setting does not affect manual invalidation via `invalidateVectors()`.

## Dirty flag convention

The pipeline in [Process](Process.md) will recompute an entity whenever the target vector is `Null`, or when a sibling field `<vectorName>_dirty` exists on the dataclass and is `True`.

Declaring the dirty flag is optional — when absent, only the null-vector case triggers recomputation. When present, it is cleared automatically on successful save.

## Ver también

- [Settings](Settings.md)
- [Process](Process.md)
- [Phrase](Phrase.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
---
id: embedder
title: Embedder
---

# Embedder

The `Embedder` class is a thin wrapper around [4D AIKit](https://developer.4d.com/docs/aikit/Classes/openai) focused on embeddings. It exposes two functions — one for a single text, one for a batch — and handles retries with exponential backoff (respecting the `Retry-After` header when present).

It is stateless beyond configuration and safe to share between processes.

## Propiedades

| Nombre de la propiedad | Tipo | Descripción |
| ---------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| `client` | cs.AIKit.OpenAI | The underlying AIKit client used for HTTP requests. |
| `maxRetries` | Integer | Maximum number of retries on transient errors. Default: `3`. |
| `backoffMs` | Integer | Base delay (ms) between retries. Doubled each attempt. |

## Class constructor

Create a embedder. All options are optional.

| Nombre del argumento | Tipo | Descripción |
| -------------------- | ------ | ----------------------------------------------------------------------------- |
| *opciones* | Object | `{client, maxRetries, backoffMs}` — any field may be omitted. |

```4d
// Default — uses cs.AIKit.OpenAI.new() internally
var $proc:=cs.EmbeddingStudio.Embedder.new()

// Provide a pre-configured AIKit client (custom API key, base URL, etc.)
var $client:=cs.AIKit.OpenAI.new({apiKey: "…"; baseURL: "https://server.ai"})
var $proc:=cs.EmbeddingStudio.Embedder.new({client: $client; maxRetries: 5; backoffMs: 1000})
```

> If the 4D AIKit component is not loaded (or is too old to provide `OpenAIProviders`), the constructor still succeeds with a `Null` client, and the first `embed()` / `embedBatch()` call throws an error whose `message` explains what is missing and whose `isAIKitMissing` property is `True`.

## Funciones

### embed()

**embed**(*text* : Text ; *model* : Text) : [cs.EmbeddingStudio.EmbedderResult](EmbedderResult.md)

Embed a single text. Returns a typed result with the embedding vector, token usage, and rate-limit state.

| Argumento | Tipo | Descripción |
| --------- | -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| *text* | Text | The text to vectorize. |
| *model* | Text | The embedding model to use (e.g. `"text-embedding-3-small"`). |
| Resultado | [cs.EmbeddingStudio.EmbedderResult](EmbedderResult.md) | Typed wrapper — `.vector` holds the embedding, `.promptTokens` / `.totalTokens` hold usage, rate-limit fields are flat camelCase. |

Throws if retries are exhausted or the API returns a non-retryable error.

```4d
var $result:=$proc.embed("it rains cats and dogs"; "text-embedding-3-small")
// $result.vector → 4D.Vector
// $result.promptTokens → Integer
// $result.totalTokens → Integer
// $result.remainingTokens → Integer (-1 if unknown)
```

### embedBatch()

**embedBatch**(*texts* : Collection ; *model* : Text) : [cs.EmbedderResult](EmbedderResult.md)

Embed a collection of texts in a single API call. Returns a typed result with vectors in the same order as inputs, token usage, and rate-limit state.

| Argumento | Tipo | Descripción |
| --------- | ------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------- |
| *texts* | Collection | Collection of Text to vectorize. Empty or `Null` returns an empty result. |
| *model* | Text | The embedding model to use. |
| Resultado | [cs.EmbedderResult](EmbedderResult.md) | Typed wrapper — `.vectors` holds the embeddings collection, token and rate-limit fields are flat camelCase. |

```4d
var $result:=$proc.embedBatch(["hello"; "world"]; "text-embedding-3-small")
// $result.vectors[0] → 4D.Vector for "hello"
// $result.vectors[1] → 4D.Vector for "world"
// $result.totalTokens → Integer (sum for the batch)
// $result.remainingTokens → Integer (after this call)
```

## Retry policy

Transient errors (HTTP 408, 409, 429, 5xx) are retried up to `maxRetries` times.

- If the response carries a `Retry-After` or `retry-after-ms` header, the embedder waits that long.
- Otherwise, it waits `backoffMs * 2^attempt`.

Non-retryable errors are thrown immediately — see [OpenAIError](https://developer.4d.com/docs/aikit/Classes/openaierror) for the thrown shape.

## Ver también

- [EmbedderResult](EmbedderResult.md)
- [Process](Process.md)
- [OpenAIEmbeddingsAPI](https://developer.4d.com/docs/aikit/Classes/openaiembeddingsapi) (AIKit)
Loading
Loading