Di halaman ini
Embedding
Jalur dasar: /v1
POST /embeddings
Membuat embedding untuk teks, ID token, atau pesan obrolan. Kirim tepat salah satu dari input atau messages. Maksimal 20 input atau percakapan per permintaan. Gambar di messages harus berupa data URI base64, dengan total payload gambar maksimal 20MB.
| Parameter | Tipe | Wajib | Deskripsi |
|---|---|---|---|
| Core Input | |||
| model | string | required | Embedding model identifier. Use GET /v1/embedding-models to list models available to your account. |
| input | string | list[string] | list[int] | list[list[int]] | list[chat messages] | required (or messages) | Text, token IDs, a list of texts, or chat messages to embed. Exactly one of input or messages must be provided. Lists are capped at 20 items per request. |
| messages | list[message] | list[list[message]] | required (or input) | One chat conversation or a batch of conversations to embed. Exactly one of input or messages must be provided. Batches are capped at 20 conversations. Use content parts for multimodal input; image URLs must be base64 data URIs (data:image/...) and the total image payload is limited to 20MB. |
| Encoding | |||
| encoding_format | "float" | "base64" | optional | Embedding encoding. "float" returns a JSON number array; "base64" returns base64-encoded binary and is more compact. Default: "float". |
| dimensions | integer | optional | Requested embedding size. Must be a positive integer when set. Model support and truncation behavior are model-dependent. |
| embed_dtype | "float32" | "float16" | "bfloat16" | "fp8_e4m3" | "fp8_e5m2" | optional | Numeric dtype used when encoding_format is "base64". Default: "float32". |
| endianness | "native" | "big" | "little" | optional | Byte order used when encoding_format is "base64". Default: "native". |
| use_activation | boolean | null | optional | Whether to apply the pooler's activation to the output. null uses the model's default, which is usually true. |
| Truncation & Tokenization | |||
| truncate_prompt_tokens | integer | optional | Truncate each input to this many tokens. Use -1 to keep all tokens, or a positive integer to keep only that many. |
| truncation_side | "left" | "right" | optional | Side to keep when truncating. "right" keeps the first N tokens; "left" keeps the last N tokens. |
| padding | "max_length" | "do_not_pad" | optional | Tokenizer padding mode. "max_length" is required by some fixed-length embedding models such as SigLIP to produce comparable embeddings. |
| add_special_tokens | boolean | optional | Whether to add model special tokens (for example BOS) to the input. Defaults to true for text input and false for chat messages. |
1curl -X POST https://api.arliai.com/v1/embeddings \
2-H "Content-Type: application/json" \
3-H "Authorization: Bearer your_api_key" \
4-d '{
5 "model": "EMBEDDING_MODEL_NAME",
6 "input": [
7 "The food was delicious.",
8 "The service was slow."
9 ],
10 "encoding_format": "float"
11}'Contoh Respons
1{
2 "id": "embd-2c0a5f6e-4f1b-4a5e-9f2f-3c7f9d1a6b8e",
3 "object": "list",
4 "created": 1760000000,
5 "model": "EMBEDDING_MODEL_NAME",
6 "data": [
7 {
8 "index": 0,
9 "object": "embedding",
10 "embedding": [0.0123, -0.0456, 0.0789]
11 },
12 {
13 "index": 1,
14 "object": "embedding",
15 "embedding": [-0.0321, 0.0678, 0.0912]
16 }
17 ],
18 "usage": {
19 "prompt_tokens": 12,
20 "total_tokens": 12
21 }
22}The embedding array above is shortened for display. For compact responses, use encoding_format: "base64". Binary responses use embed_dtype and endianness to describe how to decode them.
1curl -X POST https://api.arliai.com/v1/embeddings \
2-H "Content-Type: application/json" \
3-H "Authorization: Bearer your_api_key" \
4-d '{
5 "model": "EMBEDDING_MODEL_NAME",
6 "input": ["A compact base64 embedding"],
7 "encoding_format": "base64",
8 "embed_dtype": "float32",
9 "endianness": "native"
10}'POST /embeddings (Multimodal)
Gunakan messages dengan content parts untuk membuat embedding gambar dan teks secara bersamaan. Setiap image_url.url harus berupa data URI base64 seperti data:image/jpeg;base64,...; URL gambar jarak jauh ditolak.
1curl -X POST https://api.arliai.com/v1/embeddings \
2-H "Content-Type: application/json" \
3-H "Authorization: Bearer your_api_key" \
4-d '{
5 "model": "EMBEDDING_MODEL_NAME",
6 "messages": [
7 {
8 "role": "user",
9 "content": [
10 {"type": "text", "text": "A red bicycle leaning against a wall."},
11 {
12 "type": "image_url",
13 "image_url": {
14 "url": "data:image/jpeg;base64,your_base64_encoded_image"
15 }
16 }
17 ]
18 }
19 ],
20 "encoding_format": "float"
21}'POST /embeddings (Batch Percakapan)
Kirim larik percakapan ke messages untuk membuat embedding hingga 20 percakapan dalam satu permintaan. Setiap percakapan harus berupa larik pesan yang tidak kosong.
1curl -X POST https://api.arliai.com/v1/embeddings \
2-H "Content-Type: application/json" \
3-H "Authorization: Bearer your_api_key" \
4-d '{
5 "model": "EMBEDDING_MODEL_NAME",
6 "messages": [
7 [
8 {"role": "user", "content": "First conversation to embed."}
9 ],
10 [
11 {"role": "user", "content": "Second conversation to embed."}
12 ]
13 ]
14}'