Unity Gateway 빠른 시작

첫 요청을 Unity Gateway를 통해 OpenAI 호환 엔드포인트에 전송하세요.

요구 사항

Authenticate

시작하려면 개인 액세스 토큰을 사용하세요. OAuth는 운영 환경에서 권장됩니다. DATABRICKS_TOKEN을 작업 공간의 토큰으로 설정하세요.

개인용 액세스 토큰

개인 액세스 토큰 내보내기:

export DATABRICKS_TOKEN=<your-personal-access-token>

OAuth

Azure Databricks workspace URL로 교체하세요<workspace-url>. 그 후 Azure Databricks CLI로 로그인하여 단기간 사용 가능한 OAuth 토큰을 내보내세요:

databricks auth login --host https://<workspace-url>
export DATABRICKS_TOKEN=$(databricks auth token --host https://<workspace-url> | jq -r .access_token)

모델을 선택하세요

Azure Databricks는 UI의 스키마 아래 system.ai바로 둘러볼 수 있는 즉시 사용 가능한 모델을 제공하며, 지원되는 모델 전체 목록은 여기에서 확인할 수 있습니다.

이 빠른 시작에서는 system.ai.gpt-5-2를 사용합니다. 다른 모델을 조회하려면 해당 모델의 정규화된 전체 이름으로 바꾸세요.

요청을 보내세요

Azure Databricks workspace URL로 교체하세요<workspace-url>.

Bash

curl https://<workspace-url>/ai-gateway/mlflow/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $DATABRICKS_TOKEN" \
  -d '{
    "model": "system.ai.gpt-5-2",
    "max_output_tokens": 256,
    "input": [
      {
        "role": "user",
        "content": [{"type": "input_text", "text": "Hello!"}]
      },
      {
        "role": "assistant",
        "content": [{"type": "output_text", "text": "Hello! How can I assist you today?"}]
      },
      {
        "role": "user",
        "content": [{"type": "input_text", "text": "What is Databricks?"}]
      }
    ]
  }'

Python

from openai import OpenAI
import os

client = OpenAI(
  api_key=os.environ.get("DATABRICKS_TOKEN"),
  base_url="https://<workspace-url>/ai-gateway/mlflow/v1",
)

response = client.responses.create(
  model="system.ai.gpt-5-2",
  max_output_tokens=256,
  input=[
    {"role": "user", "content": [{"type": "input_text", "text": "Hello!"}]},
    {"role": "assistant", "content": [{"type": "output_text", "text": "Hello! How can I assist you today?"}]},
    {"role": "user", "content": [{"type": "input_text", "text": "What is Databricks?"}]},
  ],
)

print(response.output)

TypeScript

import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.DATABRICKS_TOKEN,
  baseURL: 'https://<workspace-url>/ai-gateway/mlflow/v1',
});

const response = await client.responses.create({
  model: 'system.ai.gpt-5-2',
  max_output_tokens: 256,
  input: [
    { role: 'user', content: [{ type: 'input_text', text: 'Hello!' }] },
    { role: 'assistant', content: [{ type: 'output_text', text: 'Hello! How can I assist you today?' }] },
    { role: 'user', content: [{ type: 'input_text', text: 'What is Databricks?' }] },
  ],
});

console.log(response.output);

요청 보기

카탈로그 탐색기에서 쿼리한 모델(system.ai.gpt-5-2)을 열고 메트릭 탭을 선택하면 방금 보낸 요청과 토큰 사용 및 지연 시간을 사용 기록에서 확인할 수 있습니다. Unity Gateway 관측성을 참조하세요.

다음 단계