주요 콘텐츠로 건너뛰기

이 브라우저는 더 이상 지원되지 않습니다.

최신 기능, 보안 업데이트, 기술 지원을 이용하려면 Microsoft Edge로 업그레이드하세요.

Microsoft Edge 다운로드 Internet Explorer 및 Microsoft Edge에 대한 추가 정보
microsoft-foundry.rest.security.o-auth2-auth

Embeddings

Create an embedding

POST /openai/v1/embeddings

Creates an embedding from the supplied request.

요청 본문

The request body.

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

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.

(다음 버전 중 하나)
string
string[]
OpenAI.integer[]
OpenAI.integer[][]
model string | enum 필수

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.

다음 중 하나:
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.

응답

The request has succeeded.

본문

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

The list of embeddings generated by the model.

model string 필수

The name of the model used to generate the embedding.

object enum 필수

The object type, which is always "list".

list
usage OpenAI.CreateEmbeddingResponseUsage 필수
prompt_tokens integer 필수
total_tokens integer 필수

Client error

본문

Content-Type: application/json
error OpenAI.Error 필수
code string | null 필수
message string 필수
param string | null
type string
misalignment OpenAI.MisalignmentErrorDetailsResource
review_target string | null
error_type string | enum
다음 중 하나:
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 필수

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

Server error

본문

Content-Type: application/json
error OpenAI.Error 필수
code string | null 필수
message string 필수
param string | null
type string
misalignment OpenAI.MisalignmentErrorDetailsResource
review_target string | null
error_type string | enum
다음 중 하나:
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 필수

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

요청

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)

응답

{
  "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
  }
}
ko-kr
사용자의 개인 정보 보호 선택
  • AI 고지 사항
  • 이전 버전
  • 블로그
  • 참가
  • 개인 정보 보호
  • 소비자 건강 개인 정보
  • 사용 조건
  • 상표
  • © Microsoft 2026