Unity Gateway hızlı başlangıç

İlk talebinizi OpenAI uyumlu uç noktaya karşı Unity Gateway üzerinden gönderin.

Gereksinimler

Authenticate

Başlamak için kişisel erişim tokenı kullanın. Üretim kullanım durumları için OAuth önerilir. DATABRICKS_TOKEN öğesini çalışma alanınızın belirtecine ayarlayın.

Kişisel erişim belirteci

Kişisel erişim tokenı dışa aktarın:

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

OAuth

Azure Databricks çalışma alanı URL'nizi kullanın<workspace-url>. Sonra Azure Databricks CLI ile giriş yapın ve kısa ömürlü bir OAuth token'ı dışa aktarın:

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

Bir model seçin

Azure Databricks, şema altında arayüzde system.ai göz atabileceğiniz veya desteklenen modellerin tam listesini buradan görebileceğiniz hazır modeller sunar.

Bu hızlı başlangıçta system.ai.gpt-5-2 kullanılır. Farklı bir modeli sorgulamak için, tam nitelikli adını değiştirin.

İsteğinizi gönderin

Azure Databricks çalışma alanı URL'nizi kullanın<workspace-url>.

Bash (Bir komut dilidir)

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);

İsteğinizi görün

Sorguladığınız modeli (system.ai.gpt-5-2) Katalog Explorer'da açın ve Metrikler sekmesini seçin; böylece kullanım geçmişinde gönderdiğiniz isteği, token kullanımı ve gecikmesini görün. Bkz. Unity Gateway gözlemlenebilirliği.

Sonraki Adımlar