Ana içeriğe atla

Bu tarayıcı artık desteklenmiyor.

En son özelliklerden, güvenlik güncelleştirmelerinden ve teknik destekten faydalanmak için Microsoft Edge’e yükseltin.

Microsoft Edge'i indirin Internet Explorer ve Microsoft Edge hakkında daha fazla bilgi
microsoft-foundry.rest.security.o-auth2-auth

Embeddings

Create an embedding

POST /openai/v1/embeddings

Creates an embedding from the supplied request.

İstek Gövdesi

The request body.

Content-Type: application/json
input string | string[] | OpenAI.integer[] | OpenAI.integer[][] gerekli

Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array of strings or array of token arrays. The input must not exceed the max input tokens for the model (8192 tokens for all embedding models), cannot be an empty string, and any array must be 2048 dimensions or less. Example Python code for counting tokens. In addition to the per-input token limit, all embedding models enforce a maximum of 300,000 tokens summed across all inputs in a single request.

Aşağıdakilerden biri:
string
string[]
OpenAI.integer[]
OpenAI.integer[][]
model string | enum gerekli

ID of the model to use. You can use the List models API to see all of your available models, or see our Model overview for descriptions of them.

Aşağıdakilerden biri:
string
enum
text-embedding-ada-002text-embedding-3-smalltext-embedding-3-large
encoding_format enum

The format to return the embeddings in. Can be either float or base64.

floatbase64
dimensions integer
user string

A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more.

Yanıtlar

The request has succeeded.

Gövde

Content-Type: application/json
data OpenAI.Embedding[] gerekli

The list of embeddings generated by the model.

model string gerekli

The name of the model used to generate the embedding.

object enum gerekli

The object type, which is always "list".

list
usage OpenAI.CreateEmbeddingResponseUsage gerekli
prompt_tokens integer gerekli
total_tokens integer gerekli

Client error

Gövde

Content-Type: application/json
error OpenAI.Error gerekli
code string | null gerekli
message string gerekli
param string | null
type string
misalignment OpenAI.MisalignmentErrorDetailsResource
review_target string | null
error_type string | enum
Aşağıdakilerden biri:
string
enum
potentially_unintended_data_transferpotentially_unintended_data_accesspotentially_unintended_destructive_activityother
detailed_explanation string

The public explanation for this block.

steer OpenAI._MisalignmentSteer
message string gerekli

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

Server error

Gövde

Content-Type: application/json
error OpenAI.Error gerekli
code string | null gerekli
message string gerekli
param string | null
type string
misalignment OpenAI.MisalignmentErrorDetailsResource
review_target string | null
error_type string | enum
Aşağıdakilerden biri:
string
enum
potentially_unintended_data_transferpotentially_unintended_data_accesspotentially_unintended_destructive_activityother
detailed_explanation string

The public explanation for this block.

steer OpenAI._MisalignmentSteer
message string gerekli

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

İstek

curl https://api.openai.com/v1/embeddings \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": "The food was delicious and the waiter...",
    "model": "text-embedding-ada-002",
    "encoding_format": "float"
  }'
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ.get("OPENAI_API_KEY"),  # This is the default and can be omitted
)
create_embedding_response = client.embeddings.create(
    input="The quick brown fox jumped over the lazy dog",
    model="text-embedding-3-small",
)
print(create_embedding_response.data)
import OpenAI from "openai";

const openai = new OpenAI();

async function main() {
  const embedding = await openai.embeddings.create({
    model: "text-embedding-ada-002",
    input: "The quick brown fox jumped over the lazy dog",
    encoding_format: "float",
  });

  console.log(embedding);
}

main();
using System;

using OpenAI.Embeddings;

EmbeddingClient client = new(
    model: "text-embedding-3-small",
    apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")
);

OpenAIEmbedding embedding = client.GenerateEmbedding(input: "The quick brown fox jumped over the lazy dog");
ReadOnlyMemory<float> vector = embedding.ToFloats();

for (int i = 0; i < vector.Length; i++)
{
    Console.WriteLine($"  [{i,4}] = {vector.Span[i]}");
}
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});

const createEmbeddingResponse = await client.embeddings.create({
  input: 'The quick brown fox jumped over the lazy dog',
  model: 'text-embedding-3-small',
});

console.log(createEmbeddingResponse.data);
package main

import (
    "context"
    "fmt"

    "github.com/openai/openai-go"
    "github.com/openai/openai-go/option"
)

func main() {
    client := openai.NewClient(
        option.WithAPIKey("My API Key"),
    )
    createEmbeddingResponse, err := client.Embeddings.New(context.TODO(), openai.EmbeddingNewParams{
        Input: openai.EmbeddingNewParamsInputUnion{
            OfString: openai.String("The quick brown fox jumped over the lazy dog"),
        },
        Model: openai.EmbeddingModelTextEmbedding3Small,
    })
    if err != nil {
        panic(err.Error())
    }
    fmt.Printf("%+v
", createEmbeddingResponse.Data)
}
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.embeddings.CreateEmbeddingResponse;
import com.openai.models.embeddings.EmbeddingCreateParams;
import com.openai.models.embeddings.EmbeddingModel;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        EmbeddingCreateParams params = EmbeddingCreateParams.builder()
            .input("The quick brown fox jumped over the lazy dog")
            .model(EmbeddingModel.TEXT_EMBEDDING_3_SMALL)
            .build();
        CreateEmbeddingResponse createEmbeddingResponse = client.embeddings().create(params);
    }
}
require "openai"

openai = OpenAI::Client.new(api_key: "My API Key")

create_embedding_response = openai.embeddings.create(
  input: "The quick brown fox jumped over the lazy dog",
  model: :"text-embedding-3-small"
)

puts(create_embedding_response)

Response

{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "embedding": [
        0.0023064255,
        -0.009327292,
        .... (1536 floats total for ada-002)
        -0.0028842222,
      ],
      "index": 0
    }
  ],
  "model": "text-embedding-ada-002",
  "usage": {
    "prompt_tokens": 8,
    "total_tokens": 8
  }
}
tr-tr
Gizlilik Tercihleriniz
  • AI Bildirim
  • Önceki Sürümler
  • Blog
  • Katkıda Bulunun
  • Gizlilik
  • Tüketici Sağlığı Gizliliği
  • Kullanım Koşulları
  • Ticari Markalar
  • © Microsoft 2026