文本向量
把文本转成向量表示(用量与对话合并计费)。
/openai/v1/embeddings● 支持请求体
modelstring必填The model to use for embeddings
已验证生效。
dimensionsinteger可选◐ 部分支持The number of dimensions for the output embeddings
仅 text-embedding-3-small、qwen3-vl-embedding 支持已测的 256 维;text-embedding-3-small 也支持 512,100 返回 400。bge-m3、qwen3-embedding-0.6b、doubao-embedding-vision 的 256 维返回 400。
encoding_formatstring可选The format of the output embeddings
float 与 base64 均支持;base64 为向量的二进制编码。
inputstring | array必填◐ 部分支持Text, token, or multimodal input(s) to embed
文本及文本数组生效;token 整数数组返回 400。图片仅 qwen3-vl-embedding、doubao-embedding-vision 支持;text-embedding-3-small 的 16 条批量返回 400。
input_typestring可选◐ 部分支持The type of input (e.g. search_query, search_document)
query/document 在 bge-m3、qwen3-embedding-0.6b 生效;search_query 返回 400;text-embedding-3-small 接受但当前不生效。
providerobject可选◐ 部分支持Provider routing preferences for the request.
bge-m3、qwen3-embedding-0.6b 返回 400;text-embedding-3-small 接受,但效果不可观测。
▸ 展开子字段(13)
allow_fallbacksboolean可选Whether to allow backup providers to serve requests - true: (default) when the primary provider (or your custom providers in "order") is unavailable, use the next best provider. - false: use only the primary/custom provider, and return the upstream error if it's unavailable.
data_collectionstring可选Data collection setting. If no available model provider meets the requirement, your request will return an error. - allow: (default) allow providers which store user data non-transiently and may train on it - deny: use only providers which do not collect user data.
enforce_distillable_textboolean可选Whether to restrict routing to only models that allow text distillation. When true, only models where the author has allowed distillation will be used.
ignorearray可选List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request.
max_priceobject可选The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion.
onlyarray可选List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request.
orderarray可选An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message.
preferred_max_latencynumber | object可选Preferred maximum latency (in seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints above the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold.
preferred_min_throughputnumber | object可选Preferred minimum throughput (in tokens per second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints below the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold.
quantizationsarray可选A list of quantization levels to filter the provider by.
require_parametersboolean可选Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest.
sortstring | object可选The sorting strategy to use for this request, if "order" is not specified. When set, no load balancing is performed.
zdrboolean可选Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used.
session_idstring可选◐ 部分支持A unique identifier for grouping related requests (e.g., a conversation or agent workflow). Used for observability grouping in Broadcast and private logging; never sent to the provider. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters.
bge-m3、qwen3-embedding-0.6b 返回 400;text-embedding-3-small 接受,但效果不可观测。
traceobject可选◐ 部分支持Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations.
bge-m3、qwen3-embedding-0.6b 返回 400;text-embedding-3-small 接受,但效果不可观测。
▸ 展开子字段(5)
generation_namestring可选Name of this generation in the trace.
parent_span_idstring可选Id of the parent span in the trace.
span_namestring可选Name of this request's span in the trace.
trace_idstring可选Id that groups several requests into one trace.
trace_namestring可选Name of the trace.
userstring可选◐ 部分支持A unique identifier for the end-user
bge-m3、qwen3-embedding-0.6b 返回 400;text-embedding-3-small 接受,但效果不可观测。
返回
200 list
转发方式与对话(chat completions)一致,用量算在同一份计费里。 未知顶层字段原样转发给同协议上游,由上游决定是否接受;已声明字段的类型与取值范围仍会校验,不合法时返回 400 并点名字段。
错误按 OpenAI 格式返回,参见 错误码
响应
HTTP 200
Embedding response
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| data | array<object> | List of embedding objects |
| data[].embedding | array<number> | string | Embedding vector as an array of floats or a base64 string |
| data[].index | integer | Index of the embedding in the input list |
| data[].object | string | |
| id | string | Unique identifier for the embeddings response |
| model | string | The model used for embeddings |
| object | string | |
| usage | object | Token usage statistics |
| usage.cost | number | Cost of the request in credits |
| usage.cost_details | object | null | Breakdown of upstream inference costs |
| usage.is_byok | boolean | Whether a request was made using a Bring Your Own Key configuration |
| usage.prompt_tokens | integer | Number of tokens in the input |
| usage.prompt_tokens_details | object | Per-modality token breakdown. Only present when the input contains 2+ modalities (e.g. text + image) and the upstream provider returns modality-level usage data. Only non-zero modality counts are included. |
| usage.total_tokens | integer | Total number of tokens used |
text/event-stream — chunk / 事件对象
| 名称 | 类型 | 说明 |
|---|---|---|
| $ | string | Not used for embeddings - embeddings do not support streaming |