Sedang menampilkan:
Versi - Beralih ke versi untuk portal Foundry baru
Azure model penalaran OpenAI dirancang untuk mengatasi tugas penalaran dan pemecahan masalah dengan peningkatan fokus dan kemampuan. Model-model ini menghabiskan lebih banyak waktu untuk memproses dan memahami permintaan pengguna, membuatnya sangat kuat di bidang-bidang seperti sains, pengodean, dan matematika dibandingkan dengan iterasi sebelumnya.
Kemampuan utama model penalaran:
- Pembuatan Kode Kompleks: Mampu menghasilkan algoritma dan menangani tugas pengkodean tingkat lanjut untuk mendukung pengembang.
- Pemecahan Masalah Tingkat Lanjut: Ideal untuk sesi curah otak yang komprehensif dan mengatasi tantangan multifaktor.
- Perbandingan Dokumen Kompleks: Sempurna untuk menganalisis kontrak, file kasus, atau dokumen hukum untuk mengidentifikasi perbedaan yang halus.
- Instruksi Mengikuti dan Manajemen Alur Kerja: Sangat efektif untuk mengelola alur kerja yang membutuhkan konteks yang lebih pendek.
Prasyarat
Penggunaan
Model ini saat ini tidak mendukung serangkaian parameter yang sama dengan model lain yang menggunakan API penyelesaian obrolan.
API penyelesaian obrolan lengkap
using Azure.Identity;
using OpenAI;
using OpenAI.Chat;
using System.ClientModel.Primitives;
#pragma warning disable OPENAI001 //currently required for token based authentication
BearerTokenPolicy tokenPolicy = new(
new DefaultAzureCredential(),
"https://ai.azure.com/.default");
ChatClient client = new(
model: "o4-mini",
authenticationPolicy: tokenPolicy,
options: new OpenAIClientOptions()
{
Endpoint = new Uri("https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1")
}
);
ChatCompletionOptions options = new ChatCompletionOptions
{
MaxOutputTokenCount = 100000
};
ChatCompletion completion = client.CompleteChat(
new DeveloperChatMessage("You are a helpful assistant"),
new UserChatMessage("Tell me about the bitter lesson")
);
Console.WriteLine($"[ASSISTANT]: {completion.Content[0].Text}");
Microsoft Entra ID:
Jika Anda baru menggunakan Microsoft Entra ID untuk autentikasi, lihat Cara mengonfigurasi Azure OpenAI di Microsoft Foundry Models dengan autentikasi Microsoft Entra ID.
from openai import OpenAI
from azure.identity import DefaultAzureCredential, get_bearer_token_provider
token_provider = get_bearer_token_provider(
DefaultAzureCredential(), "https://ai.azure.com/.default"
)
client = OpenAI(
base_url = "https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/",
api_key=token_provider,
)
response = client.chat.completions.create(
model="YOUR-DEPLOYMENT-NAME", # replace with your model deployment name
messages=[
{"role": "user", "content": "What steps should I think about when writing my first Python API?"},
],
max_completion_tokens = 5000
)
print(response.model_dump_json(indent=2))
Kunci API:
import os
from openai import OpenAI
client = OpenAI(
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
base_url="https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/",
)
response = client.chat.completions.create(
model="YOUR-DEPLOYMENT-NAME", # replace with your model deployment name
messages=[
{"role": "user", "content": "What steps should I think about when writing my first Python API?"},
],
max_completion_tokens = 5000
)
print(response.model_dump_json(indent=2))
curl -X POST "https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $AZURE_OPENAI_AUTH_TOKEN" \
-d '{
"model": "gpt-5",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What steps should I think about when writing my first Python API?"}
],
"max_completion_tokens": 1000
}'
Keluaran API Penyelesaian Obrolan Python:
{
"id": "chatcmpl-AEj7pKFoiTqDPHuxOcirA9KIvf3yz",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"logprobs": null,
"message": {
"content": "Writing your first Python API is an exciting step in developing software that can communicate with other applications. An API (Application Programming Interface) allows different software systems to interact with each other, enabling data exchange and functionality sharing. Here are the steps you should consider when creating your first Python API...truncated for brevity.",
"refusal": null,
"role": "assistant",
"function_call": null,
"tool_calls": null
},
"content_filter_results": {
"hate": {
"filtered": false,
"severity": "safe"
},
"protected_material_code": {
"filtered": false,
"detected": false
},
"protected_material_text": {
"filtered": false,
"detected": false
},
"self_harm": {
"filtered": false,
"severity": "safe"
},
"sexual": {
"filtered": false,
"severity": "safe"
},
"violence": {
"filtered": false,
"severity": "safe"
}
}
}
],
"created": 1728073417,
"model": "o1-2024-12-17",
"object": "chat.completion",
"service_tier": null,
"system_fingerprint": "fp_503a95a7d8",
"usage": {
"completion_tokens": 1843,
"prompt_tokens": 20,
"total_tokens": 1863,
"completion_tokens_details": {
"audio_tokens": null,
"reasoning_tokens": 448
},
"prompt_tokens_details": {
"audio_tokens": null,
"cached_tokens": 0
}
},
"prompt_filter_results": [
{
"prompt_index": 0,
"content_filter_results": {
"custom_blocklists": {
"filtered": false
},
"hate": {
"filtered": false,
"severity": "safe"
},
"jailbreak": {
"filtered": false,
"detected": false
},
"self_harm": {
"filtered": false,
"severity": "safe"
},
"sexual": {
"filtered": false,
"severity": "safe"
},
"violence": {
"filtered": false,
"severity": "safe"
}
}
}
]
}
Upaya penalaran
Catatan
Model penalaran memiliki reasoning_tokens sebagai bagian completion_tokens_details dari dalam respons model. Ini adalah token tersembunyi yang tidak dikembalikan sebagai bagian dari konten respons pesan tetapi digunakan oleh model untuk membantu menghasilkan jawaban akhir atas permintaan Anda.
reasoning_effortdapat diatur ke low, , atau medium untuk semua model penalaran kecuali higho1-mini. Semakin tinggi pengaturan upaya, semakin lama model akan menghabiskan pemrosesan permintaan, yang umumnya akan menghasilkan jumlah yang lebih besar dari reasoning_tokens.
Pesan pengembang
Pesan pengembang ("role": "developer") secara fungsional sama dengan pesan sistem.
Menambahkan pesan pengembang ke contoh kode sebelumnya akan terlihat sebagai berikut:
using Azure.Identity;
using OpenAI;
using OpenAI.Chat;
using System.ClientModel.Primitives;
#pragma warning disable OPENAI001 //currently required for token based authentication
BearerTokenPolicy tokenPolicy = new(
new DefaultAzureCredential(),
"https://ai.azure.com/.default");
ChatClient client = new(
model: "o4-mini",
authenticationPolicy: tokenPolicy,
options: new OpenAIClientOptions()
{
Endpoint = new Uri("https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1")
}
);
ChatCompletionOptions options = new ChatCompletionOptions
{
ReasoningEffortLevel = ChatReasoningEffortLevel.Low,
MaxOutputTokenCount = 100000
};
ChatCompletion completion = client.CompleteChat(
new DeveloperChatMessage("You are a helpful assistant"),
new UserChatMessage("Tell me about the bitter lesson")
);
Console.WriteLine($"[ASSISTANT]: {completion.Content[0].Text}");
Microsoft Entra ID:
Jika Anda baru menggunakan Microsoft Entra ID untuk autentikasi, lihat Cara mengonfigurasi Azure OpenAI dengan autentikasi Microsoft Entra ID.
from openai import OpenAI
from azure.identity import DefaultAzureCredential, get_bearer_token_provider
token_provider = get_bearer_token_provider(
DefaultAzureCredential(), "https://ai.azure.com/.default"
)
client = OpenAI(
base_url="https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/",
api_key=token_provider,
)
response = client.chat.completions.create(
model="YOUR-DEPLOYMENT-NAME", # replace with your model deployment name
messages=[
{"role": "developer", "content": "You are a helpful assistant."},
{"role": "user", "content": "What steps should I think about when writing my first Python API?"},
],
max_completion_tokens=5000,
reasoning_effort="medium", # low, medium, or high
)
print(response.model_dump_json(indent=2))
Kunci API:
import os
from openai import OpenAI
client = OpenAI(
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
base_url="https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/",
)
response = client.chat.completions.create(
model="gpt-5-mini", # replace with the model deployment name of your o1 deployment.
messages=[
{"role": "developer","content": "You are a helpful assistant."}, # optional equivalent to a system message for reasoning models
{"role": "user", "content": "What steps should I think about when writing my first Python API?"},
],
max_completion_tokens = 5000,
reasoning_effort = "medium" # low, medium, or high
)
print(response.model_dump_json(indent=2))
curl -X POST "https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $AZURE_OPENAI_AUTH_TOKEN" \
-d '{
"model": "gpt-5",
"messages": [
{"role": "developer", "content": "You are a helpful assistant."},
{"role": "user", "content": "What steps should I think about when writing my first Python API?"}
],
"max_completion_tokens": 1000,
"reasoning_effort": "medium"
}'
Keluaran API Penyelesaian Obrolan Python:
{
"id": "chatcmpl-CaODNsQOHoRLcb9JVSKYY1e2Iss5s",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"logprobs": null,
"message": {
"content": "Here's a practical, beginner‑friendly checklist to guide you through writing your first Python API, from idea to production.\n\n1) Clarify goals and constraints\n- Who will use it (internal team, public), what problems it solves, expected traffic, latency requirements.\n- Resources you'll expose (users, orders, etc.) and core operations.\n- Non‑functional needs: security, compliance, uptime, scalability.\n\n2) Choose your API style\n- REST (most common for CRUD and simple integrations).\n- GraphQL (flexible queries, more complex to secure/monitor).\n- gRPC (high‑performance, strongly typed, good for service‑to‑service).\n- For a first API, REST + JSON is usually best.\n\n3) Design the contract first\n- Draft an OpenAPI/Swagger spec: endpoints, request/response schemas, status codes, error model.\n- Decide naming conventions, pagination, filtering, sorting.\n- Define consistent time/date format (ISO‑8601, UTC), ID format, and field casing.\n- Plan versioning strategy (e.g., /v1) and deprecation policy.\n\n4) Plan security and auth\n- Pick auth: API keys for simple internal use; OAuth2/JWT for user auth; mTLS for service‑to‑service.\n- CORS policy for browsers; HTTPS everywhere; security headers.\n- Validate all inputs; avoid leaking stack traces; define rate limits and quotas.\n\n5) Pick your Python stack\n- Frameworks: FastAPI (great typing, validation, auto docs), Flask (minimal), Django REST Framework (batteries included).\n- ASGI/WSGI server: Uvicorn or Gunicorn.\n- Data layer: PostgreSQL + SQLAlchemy/Django ORM; migrations with Alembic/Django migrations.\n- Caching: Redis (optional).\n- Background jobs: Celery/RQ (if needed).\n\n6) Set up the project\n- Create a virtual environment; choose dependency management (pip, Poetry).\n- Establish project structure (app, api, models, services, tests).\n- Add linting/formatting/type checks: black, isort, flake8, mypy; pre‑commit hooks.\n- Configuration via environment variables; secrets via a manager (not in code).\n\n7) Implement core functionality\n- Build endpoints that match your spec; keep business logic in a service layer, not in route handlers.\n- Schema validation (Pydantic with FastAPI, Marshmallow for Flask).\n- Consistent responses and errors; use clear status codes (201 create, 204 no content, 400/404/409/422, 500).\n- Pagination and filtering; idempotency for certain POST operations; ETags/conditional requests if useful.\n\n8) Error handling and an error model\n- Define a standard error body (code, message, details, correlation_id).\n- Log errors with context; don't expose internal details to clients.\n\n9) Testing strategy\n- Unit tests for services/validators.\n- Integration tests for endpoints (pytest + httpx/requests) with a test database.\n- Contract tests to assert the API matches the OpenAPI spec.\n- Mock external services; measure coverage and focus on critical paths.\n\n10) Documentation and developer experience\n- Auto‑generated docs (FastAPI provides Swagger/ReDoc).\n- Write examples for each endpoint; onboarding and usage notes.\n- Keep a changelog and release notes.\n\n11) Observability and reliability\n- Structured logging (JSON), include request IDs/correlation IDs.\n- Metrics (requests, latency, error rates), health/readiness endpoints.\n- Tracing (OpenTelemetry) if you have multiple services.\n- Error reporting (Sentry or similar).\n\n12) Deployment and operations\n- Containerize with Docker; follow 12‑factor app principles.\n- CI/CD pipeline: run tests, build image, deploy, run migrations.\n- Choose hosting (Render, Fly.io, Railway, Heroku, AWS/GCP/Azure).\n- Configure scaling, connection pools, and timeouts; use a reverse proxy if needed.\n\n13) Performance and data concerns\n- Index your database; avoid N+1 queries; use connection pooling.\n- Load test key endpoints; profile hotspots.\n- Caching strategies where appropriate; consider async I/O for high‑concurrency workloads.\n\n14) Versioning and lifecycle management\n- Keep backward compatibility for minor changes; add fields rather than changing semantics.\n- Communicate deprecations; sunset old versions with a timeline.\n\n15) Governance, compliance, and safety\n- Handle PII correctly; data retention and audit logs if required.\n- Least‑privilege DB access; rotate secrets; review third‑party dependencies.\n\nBeginner‑friendly defaults\n- FastAPI + Pydantic + Uvicorn\n- PostgreSQL + SQLAlchemy + Alembic\n- pytest + httpx + coverage\n- black, isort, flake8, mypy, pre‑commit\n- Docker + simple CI (GitHub Actions) + a managed host\n\nCommon pitfalls to avoid\n- Inconsistent status codes or error formats.\n- Weak input validation and missing authentication.\n- Business logic inside route handlers (hard to test/maintain).\n- No migrations or tests; no logging/metrics.\n- Ignoring pagination and timezones; returning unbounded lists.\n\nIf you share whether it's public vs internal, expected traffic, and preferred framework, I can tailor this to a concrete starter plan and recommended tools.",
"refusal": null,
"role": "assistant",
"annotations": [],
"audio": null,
"function_call": null,
"tool_calls": null
},
"content_filter_results": {
"hate": {
"filtered": false,
"severity": "safe"
},
"protected_material_code": {
"filtered": false,
"detected": false
},
"protected_material_text": {
"filtered": false,
"detected": false
},
"self_harm": {
"filtered": false,
"severity": "safe"
},
"sexual": {
"filtered": false,
"severity": "safe"
},
"violence": {
"filtered": false,
"severity": "safe"
}
}
}
],
"created": 1762788925,
"model": "gpt-5-2025-08-07",
"object": "chat.completion",
"service_tier": null,
"system_fingerprint": null,
"usage": {
"completion_tokens": 2919,
"prompt_tokens": 29,
"total_tokens": 2948,
"completion_tokens_details": {
"accepted_prediction_tokens": 0,
"audio_tokens": 0,
"reasoning_tokens": 1792,
"rejected_prediction_tokens": 0
},
"prompt_tokens_details": {
"audio_tokens": 0,
"cached_tokens": 0
}
},
"prompt_filter_results": [
{
"prompt_index": 0,
"content_filter_results": {
"hate": {
"filtered": false,
"severity": "safe"
},
"jailbreak": {
"filtered": false,
"detected": false
},
"self_harm": {
"filtered": false,
"severity": "safe"
},
"sexual": {
"filtered": false,
"severity": "safe"
},
"violence": {
"filtered": false,
"severity": "safe"
}
}
}
]
}
Ringkasan penalaran
Saat menggunakan model penalaran terbaru dengan API Respons , Anda dapat menggunakan parameter ringkasan penalaran untuk menerima ringkasan rantai pemikiran model.
Penting
Mencoba mengekstrak penalaran mentah melalui metode selain parameter ringkasan penalaran tidak didukung, dapat melanggar Kebijakan Penggunaan yang Dapat Diterima, dan dapat mengakibatkan pembatasan atau penangguhan saat terdeteksi.
using OpenAI;
using OpenAI.Responses;
using System.ClientModel.Primitives;
using Azure.Identity;
#pragma warning disable OPENAI001 //currently required for token based authentication
BearerTokenPolicy tokenPolicy = new(
new DefaultAzureCredential(),
"https://ai.azure.com/.default");
OpenAIResponseClient client = new(
model: "o4-mini",
authenticationPolicy: tokenPolicy,
options: new OpenAIClientOptions()
{
Endpoint = new Uri("https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1")
}
);
OpenAIResponse response = await client.CreateResponseAsync(
userInputText: "What's the optimal strategy to win at poker?",
new ResponseCreationOptions()
{
ReasoningOptions = new ResponseReasoningOptions()
{
ReasoningEffortLevel = ResponseReasoningEffortLevel.High,
ReasoningSummaryVerbosity = ResponseReasoningSummaryVerbosity.Auto,
},
});
// Get the reasoning summary from the first OutputItem (ReasoningResponseItem)
Console.WriteLine("=== Reasoning Summary ===");
foreach (var item in response.OutputItems)
{
if (item is ReasoningResponseItem reasoningItem)
{
foreach (var summaryPart in reasoningItem.SummaryParts)
{
if (summaryPart is ReasoningSummaryTextPart textPart)
{
Console.WriteLine(textPart.Text);
}
}
}
}
Console.WriteLine("\n=== Assistant Response ===");
// Get the assistant's output
Console.WriteLine(response.GetOutputText());
Anda harus meningkatkan pustaka klien OpenAI Anda untuk akses ke parameter terbaru.
pip install openai --upgrade
Microsoft Entra ID:
from openai import OpenAI
from azure.identity import DefaultAzureCredential, get_bearer_token_provider
token_provider = get_bearer_token_provider(
DefaultAzureCredential(), "https://ai.azure.com/.default"
)
client = OpenAI(
base_url = "https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/",
api_key=token_provider,
)
response = client.responses.create(
input="Tell me about the curious case of neural text degeneration",
model="gpt-5", # replace with model deployment name
reasoning={
"effort": "medium",
"summary": "auto" # auto, concise, or detailed, gpt-5 series do not support concise
},
text={
"verbosity": "low" # New with GPT-5 models
}
)
print(response.model_dump_json(indent=2))
Kunci API:
import os
from openai import OpenAI
client = OpenAI(
base_url = "https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/",
api_key=os.getenv("AZURE_OPENAI_API_KEY")
)
response = client.responses.create(
input="Tell me about the curious case of neural text degeneration",
model="gpt-5", # replace with model deployment name
reasoning={
"effort": "medium",
"summary": "auto" # auto, concise, or detailed, gpt-5 series do not support concise
},
text={
"verbosity": "low" # New with GPT-5 models
}
)
print(response.model_dump_json(indent=2))
curl -X POST "https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $AZURE_OPENAI_AUTH_TOKEN" \
-d '{
"model": "gpt-5",
"input": "Tell me about the curious case of neural text degeneration",
"reasoning": {"summary": "auto"},
"text": {"verbosity": "low"}
}'
{
"id": "resp_689a0a3090808190b418acf12b5cc40e0fc1c31bc69d8719",
"created_at": 1754925616.0,
"error": null,
"incomplete_details": null,
"instructions": null,
"metadata": {},
"model": "gpt-5",
"object": "response",
"output": [
{
"id": "rs_689a0a329298819095d90c34dc9b80db0fc1c31bc69d8719",
"summary": [],
"type": "reasoning",
"encrypted_content": null,
"status": null
},
{
"id": "msg_689a0a33009881909fe0fcf57cba30200fc1c31bc69d8719",
"content": [
{
"annotations": [],
"text": "Neural text degeneration refers to the ways language models produce low-quality, repetitive, or vacuous text, especially when generating long outputs. It's "curious" because models trained to imitate fluent text can still spiral into unnatural patterns. Key aspects:\n\n- Repetition and loops: The model repeats phrases or sentences ("I'm sorry, but..."), often due to high-confidence tokens reinforcing themselves.\n- Loss of specificity: Vague, generic, agreeable text that avoids concrete details.\n- Drift and contradiction: The output gradually departs from context or contradicts itself over long spans.\n- Exposure bias: During training, models see gold-standard prefixes; at inference, they must condition on their own imperfect outputs, compounding errors.\n- Likelihood vs. quality mismatch: Maximizing token-level likelihood doesn't align with human preferences for diversity, coherence, or factuality.\n- Token over-optimization: Frequent, safe tokens get overused; certain phrases become attractors.\n- Entropy collapse: With greedy or low-temperature decoding, the distribution narrows too much, causing repetitive, low-entropy text.\n- Length and beam search issues: Larger beams or long generations can favor bland, repetitive sequences (the "likelihood trap").\n\nCommon mitigations:\n\n- Decoding strategies:\n - Top-k, nucleus (top-p), or temperature sampling to keep sufficient entropy.\n - Typical sampling and locally typical sampling to avoid dull but high-probability tokens.\n - Repetition penalties, presence/frequency penalties, no-repeat n-grams.\n - Contrastive decoding (and variants like DoLa) to filter generic continuations.\n - Min/max length, stop sequences, and beam search with diversity/penalties.\n\n- Training and alignment:\n - RLHF/DPO to better match human preferences for non-repetitive, helpful text.\n - Supervised fine-tuning on high-quality, diverse data; instruction tuning.\n - Debiasing objectives (unlikelihood training) to penalize repetition and banned patterns.\n - Mixture-of-denoisers or latent planning to improve long-range coherence.\n\n- Architectural and planning aids:\n - Retrieval-augmented generation to ground outputs.\n - Tool use and structured prompting to constrain drift.\n - Memory and planning modules, hierarchical decoding, or sentence-level control.\n\n- Prompting tips:\n - Ask for concise answers, set token limits, and specify structure.\n - Provide concrete constraints or content to reduce generic filler.\n - Use "say nothing if uncertain" style instructions to avoid vacuity.\n\nRepresentative papers/terms to search:\n- Holtzman et al., "The Curious Case of Neural Text Degeneration" (2020): nucleus sampling.\n- Welleck et al., "Neural Text Degeneration with Unlikelihood Training."\n- Li et al., "A Contrastive Framework for Decoding."\n- Su et al., "DoLa: Decoding by Contrasting Layers."\n- Meister et al., "Typical Decoding."\n- Ouyang et al., "Training language models to follow instructions with human feedback."\n\nIn short, degeneration arises from a mismatch between next-token likelihood and human preferences plus decoding choices; careful decoding, training objectives, and grounding help prevent it.",
"type": "output_text",
"logprobs": null
}
],
"role": "assistant",
"status": "completed",
"type": "message"
}
],
"parallel_tool_calls": true,
"temperature": 1.0,
"tool_choice": "auto",
"tools": [],
"top_p": 1.0,
"background": false,
"max_output_tokens": null,
"max_tool_calls": null,
"previous_response_id": null,
"prompt": null,
"prompt_cache_key": null,
"reasoning": {
"effort": "minimal",
"generate_summary": null,
"summary": "detailed"
},
"safety_identifier": null,
"service_tier": "default",
"status": "completed",
"text": {
"format": {
"type": "text"
}
},
"top_logprobs": null,
"truncation": "disabled",
"usage": {
"input_tokens": 16,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens": 657,
"output_tokens_details": {
"reasoning_tokens": 0
},
"total_tokens": 673
},
"user": null,
"content_filters": null,
"store": true
}
Catatan
Bahkan ketika diaktifkan, ringkasan penalaran tidak dijamin akan dihasilkan untuk setiap langkah/permintaan. Ini adalah perilaku yang diharapkan.
Python burung pipit
Model penalaran seri GPT-5 memiliki kemampuan untuk memanggil yang baru custom_tool yang disebut lark_tool. Alat ini didasarkan pada Python lark dan dapat digunakan untuk batasan output model yang lebih fleksibel.
Respons API
{
"model": "gpt-5-2025-08-07",
"input": "please calculate the area of a circle with radius equal to the number of 'r's in strawberry",
"tools": [
{
"type": "custom",
"name": "lark_tool",
"format": {
"type": "grammar",
"syntax": "lark",
"definition": "start: QUESTION NEWLINE ANSWER\nQUESTION: /[^\\n?]{1,200}\\?/\nNEWLINE: /\\n/\nANSWER: /[^\\n!]{1,200}!/"
}
}
],
"tool_choice": "required"
}
Microsoft Entra ID:
from openai import OpenAI
from azure.identity import DefaultAzureCredential, get_bearer_token_provider
token_provider = get_bearer_token_provider(
DefaultAzureCredential(), "https://ai.azure.com/.default"
)
client = OpenAI(
base_url = "https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/",
api_key=token_provider,
)
response = client.responses.create(
model="gpt-5", # replace with your model deployment name
tools=[
{
"type": "custom",
"name": "lark_tool",
"format": {
"type": "grammar",
"syntax": "lark",
"definition": "start: QUESTION NEWLINE ANSWER\nQUESTION: /[^\\n?]{1,200}\\?/\nNEWLINE: /\\n/\nANSWER: /[^\\n!]{1,200}!/"
}
}
],
input=[{"role": "user", "content": "Please calculate the area of a circle with radius equal to the number of 'r's in strawberry"}],
)
print(response.model_dump_json(indent=2))
Kunci API:
import os
from openai import OpenAI
client = OpenAI(
base_url = "https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/",
api_key=os.getenv("AZURE_OPENAI_API_KEY")
)
response = client.responses.create(
model="gpt-5", # replace with your model deployment name
tools=[
{
"type": "custom",
"name": "lark_tool",
"format": {
"type": "grammar",
"syntax": "lark",
"definition": "start: QUESTION NEWLINE ANSWER\nQUESTION: /[^\\n?]{1,200}\\?/\nNEWLINE: /\\n/\nANSWER: /[^\\n!]{1,200}!/"
}
}
],
input=[{"role": "user", "content": "Please calculate the area of a circle with radius equal to the number of 'r's in strawberry"}],
)
print(response.model_dump_json(indent=2))
Output:
{
"id": "resp_689a0cf927408190b8875915747667ad01c936c6ffb9d0d3",
"created_at": 1754926332.0,
"error": null,
"incomplete_details": null,
"instructions": null,
"metadata": {},
"model": "gpt-5",
"object": "response",
"output": [
{
"id": "rs_689a0cfd1c888190a2a67057f471b5cc01c936c6ffb9d0d3",
"summary": [],
"type": "reasoning",
"encrypted_content": null,
"status": null
},
{
"id": "msg_689a0d00e60c81908964e5e9b2d6eeb501c936c6ffb9d0d3",
"content": [
{
"annotations": [],
"text": ""strawberry" has 3 r's, so the radius is 3.\nArea = πr<sup>2</sup> = π × 3<sup>2</sup> = 9π ≈ 28.27 square units.",
"type": "output_text",
"logprobs": null
}
],
"role": "assistant",
"status": "completed",
"type": "message"
}
],
"parallel_tool_calls": true,
"temperature": 1.0,
"tool_choice": "auto",
"tools": [
{
"name": "lark_tool",
"parameters": null,
"strict": null,
"type": "custom",
"description": null,
"format": {
"type": "grammar",
"definition": "start: QUESTION NEWLINE ANSWER\nQUESTION: /[^\\n?]{1,200}\\?/\nNEWLINE: /\\n/\nANSWER: /[^\\n!]{1,200}!/",
"syntax": "lark"
}
}
],
"top_p": 1.0,
"background": false,
"max_output_tokens": null,
"max_tool_calls": null,
"previous_response_id": null,
"prompt": null,
"prompt_cache_key": null,
"reasoning": {
"effort": "medium",
"generate_summary": null,
"summary": null
},
"safety_identifier": null,
"service_tier": "default",
"status": "completed",
"text": {
"format": {
"type": "text"
}
},
"top_logprobs": null,
"truncation": "disabled",
"usage": {
"input_tokens": 139,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens": 240,
"output_tokens_details": {
"reasoning_tokens": 192
},
"total_tokens": 379
},
"user": null,
"content_filters": null,
"store": true
}
Penyelesaian Percakapan AI
{
"messages": [
{
"role": "user",
"content": "Which one is larger, 42 or 0?"
}
],
"tools": [
{
"type": "custom",
"name": "custom_tool",
"custom": {
"name": "lark_tool",
"format": {
"type": "grammar",
"grammar": {
"syntax": "lark",
"definition": "start: QUESTION NEWLINE ANSWER\nQUESTION: /[^\\n?]{1,200}\\?/\nNEWLINE: /\\n/\nANSWER: /[^\\n!]{1,200}!/"
}
}
}
}
],
"tool_choice": "required",
"model": "gpt-5-2025-08-07"
}
Ketersediaan
Ketersediaan wilayah
API dan dukungan fitur
|
Fitur |
gpt-6-astra, 2026-09-03 |
|
Keluaran terstruktur |
✅ |
|
Jendela konteks |
1.050.000 token |
|
Jumlah token input maksimum |
922.000 token |
|
Jumlah token output maksimum |
128.000 token |
|
Modalitas masukan |
Teks dan gambar |
|
Modalitas keluaran |
Text |
| API Penyelesaian Chat |
✅ (tanpa alat) |
| Respons API |
✅ |
| Streaming |
✅ |
| Fungsi/alat |
✅ (khusus API Responses saja) |
|
Upaya penalaran |
✅ (none tidak didukung) |
| Verbositas |
✅ |
logprobs |
- |
temperature |
- |
top_p |
- |
Azure OpenAI saat ini tidak mendukung perubahan tingkat upaya penalaran di tengah percakapan (configuration_update) atau pengarahan di tengah giliran (response.steer) untuk GPT-6 Astra.
Panggilan alat memerlukan API Respons. Jika Anda menggunakan alat dengan Chat Completions, ikuti panduan migrasi Responses API.
|
Fitur |
gpt-5.6-sol, 2026-06-25 |
gpt-5.6-terra, 2026-06-25 |
gpt-5.6-luna, 2026-06-25 |
gpt-5.5, 2026-04-24 |
gpt-5.4-nano, 2026-03-17 |
gpt-5.4-mini, 2026-03-17 |
gpt-5.4-pro |
gpt-5.4, 2026-03-05 |
gpt-5.3-codex, 2026-02-24 |
gpt-5.2-codex, 2026-01-14 |
gpt-5.2, 2025-12-11 |
gpt-5.1-codex-max, 2025-12-04 |
gpt-5.1, 2025-11-13 |
gpt-5.1-chat, 2025-11-13 |
gpt-5.1-codex, 2025-11-13 |
gpt-5.1-codex-mini, 2025-11-13 |
gpt-5-pro, 2025-10-06 |
gpt-5-codex, 2025-09-011 |
gpt-5, 2025-08-07 |
gpt-5-mini, 2025-08-07 |
gpt-5-nano, 2025-08-07 |
|
Pesan Pengembang |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
|
Output Terstruktur |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
|
Jendela Konteks |
1,050,000
Input: 922,000 Keluaran 128,000 |
1,050,000
Input: 922,000 Keluaran 128,000 |
1,050,000
Input: 922,000 Keluaran 128,000 |
1,050,000
Input: 922,000 Keluaran 128,000 |
400,000
Input: 272.000 Output: 128.000
|
400,000
Input: 272.000 Output: 128.000
|
1,050,000
Input: 922,000 Keluaran 128,000 |
1,050,000
Input: 922,000 Keluaran 128,000 |
400,000
Input: 272.000 Output: 128.000 |
400,000
Input: 272.000 Output: 128.000 |
400,000
Input: 272.000 Output: 128.000 |
400,000
Input: 272.000 Output: 128.000 |
400,000
Input: 272.000 Output: 128.000 |
128,000
Masukan: 111.616 Keluaran: 16.384 |
400,000
Input: 272.000 Output: 128.000 |
400,000
Input: 272.000 Output: 128.000 |
400,000
Input: 272.000 Output: 128.000 |
400,000
Input: 272.000 Output: 128.000 |
400,000
Input: 272.000 Output: 128.000 |
400,000
Input: 272.000 Output: 128.000 |
400,000
Input: 272.000 Output: 128.000 |
|
Upaya penalaran7 |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅
6 |
✅
4 |
✅ |
✅ |
✅ |
✅
5 |
✅ |
✅ |
✅ |
✅ |
|
Input gambar |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
| API Penyelesaian Chat |
✅
9 |
✅
9 |
✅
9 |
✅ |
✅ |
✅ |
- |
✅ |
- |
- |
✅ |
- |
✅ |
✅ |
- |
- |
- |
- |
✅ |
✅ |
✅ |
| Respons API |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
| Fungsi/Alat |
✅
9 |
✅
9 |
✅
9 |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
| Panggilan Perangkat Paralel1 |
✅ |
✅ |
✅ |
✅ |
✅ |
- |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
- |
✅ |
✅ |
✅ |
✅ |
✅ |
max_completion_tokens
2 |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
- |
✅ |
- |
- |
✅ |
- |
✅ |
✅ |
- |
- |
- |
- |
✅ |
✅ |
✅ |
| Pesan Sistem 3 |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
|
Ringkasan penalaran |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
|
Penalaran tersimpan8 |
✅ |
✅ |
✅ |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
| Streaming |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
- |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
1 Panggilan alat paralel tidak didukung saat reasoning_effort diatur ke minimal
2 Model pemikiran hanya akan bekerja dengan parameter max_completion_tokens saat menggunakan API Penyelesaian Obrolan. Gunakan max_output_tokens dengan API Respons.
3 Model penalaran terbaru mendukung pesan sistem untuk mempermudah migrasi. Anda tidak boleh menggunakan pesan pengembang dan pesan sistem dalam permintaan API yang sama.
4gpt-5.1reasoning_effort bernilai default ke none. Saat Anda meningkatkan dari model penalaran sebelumnya ke gpt-5.1, ingatlah bahwa Anda mungkin perlu memperbarui kode Anda untuk secara eksplisit menentukan tingkat reasoning_effort jika Anda ingin reasoning_effort tersebut dilakukan.
5gpt-5-pro hanya mendukung reasoning_efforthigh, ini adalah nilai default bahkan ketika tidak secara eksplisit diteruskan ke model.
6gpt-5.1-codex-max menambahkan dukungan untuk tingkat baru reasoning_effortxhigh yang merupakan tingkat tertinggi yang dapat digunakan untuk mengatur upaya penalaran.
7gpt-5.6, gpt-5.5, gpt-5.4, gpt-5.2, gpt-5.1, gpt-5.1-codex, gpt-5.1-codex-max, dan gpt-5.1-codex-mini mendukung 'None' sebagai nilai untuk parameter reasoning_effort. Untuk menggunakan model ini untuk menghasilkan respons tanpa penalaran, atur reasoning_effort='None'. Pengaturan ini dapat meningkatkan kecepatan.
8 Model gpt-5.6 dan yang lebih baru mendukung all_turns untuk parameter reasoning.context dan menggunakannya secara default. Model penalaran sebelumnya hanya mendukung auto dan current_turn.
9 Model gpt-5.6 mendukung API Penyelesaian Obrolan dan alat fungsi, tetapi tidak keduanya pada saat yang sama kecuali reasoning_effort adalah none. Gunakan API Respons untuk panggilan alat. Untuk detail dan solusinya, lihat Panggilan alat dengan model penalaran.
Fitur penalaran GPT-5 dan GPT-6
| Fitur |
Deskripsi |
reasoning_effort |
max hanya berfungsi dengan model GPT-6 atau GPT-5.6 dan API Respons.
xhigh hanya berfungsi dengan GPT-6, GPT-5.6, GPT-5.5, GPT-5.4, dan gpt-5.1-codex-max model.
minimal hanya berfungsi dengan model penalaran GPT-5 asli.
minimal tidak bekerja dengan gpt-5.1 atau lebih besar. * GPT-6 Astra tidak mendukung none dan memerlukan API Respons untuk panggilan alat. Dengan model GPT-5.6 pada CHAT Completions API, none adalah satu-satunya nilai yang dapat Anda gabungkan dengan alat fungsi. Lihat Pemanggilan alat dengan model penalaran.
Opsi (tergantung model): none, minimal, low, medium, high, xhigh, max |
verbosity |
Parameter baru yang memberi Anda kontrol yang lebih terperinci atas seberapa ringkas output model.
Opsi:low, medium, high. |
reasoning.context |
Mengontrol elemen penalaran yang tersedia yang akan dirender oleh model ke konteks berikutnya.
all_turns hanya berfungsi dengan model GPT-6 dan GPT-5.6, yang menggunakan opsi ini secara default.
Opsi:auto, current_turn, all_turns. |
reasoning.mode |
Memilih eksekusi standar atau pro untuk model GPT-6 dan GPT-5.6 dengan API Respons. Mode Pro melakukan lebih banyak pemrosesan model untuk suatu permintaan sebelum memberikan satu jawaban, yang meningkatkan latensi dan penggunaan token. Azure OpenAI menggunakan standard sebagai default.
Opsi:standard, pro. |
preamble |
Model penalaran seri GPT-5 memiliki kemampuan untuk menghabiskan waktu ekstra "berpikir" sebelum menjalankan panggilan fungsi/alat.
Ketika perencanaan ini terjadi, model dapat memberikan wawasan tentang langkah-langkah perencanaan dalam respons model melalui objek baru yang disebut preamble objek .
Pembuatan preamble dalam respons model tidak dijamin meskipun Anda dapat mendorong model dengan menggunakan parameter instructions dan memberikan konten seperti "Anda HARUS merencanakan secara ekstensif sebelum setiap panggilan fungsi." SELALU tampilkan rencana Anda kepada pengguna sebelum memanggil fungsi apapun. |
|
alat yang diizinkan |
Anda dapat menentukan beberapa alat di bawah tool_choice alih-alih hanya satu. |
|
jenis alat khusus |
Mengaktifkan output teks mentah (non-JSON). |
lark_tool |
Memungkinkan Anda menggunakan beberapa kemampuan Python lark untuk batasan respons model yang lebih fleksibel |
*
gpt-5-codex juga tidak mendukung reasoning_effortminimal.
Untuk informasi lebih lanjut, kami juga merekomendasikan membaca panduan pemicu GPT-5 OpenAI dan panduan fitur GPT-5 mereka.
|
Fitur |
codex-mini, 2025-05-16 |
o3-pro, 2025-06-10 |
o4-mini, 2025-04-16 |
o3, 2025-04-16 |
o3-mini, 2025-01-31 |
o1, 2024-12-17 |
|
Pesan Pengembang |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
|
Output Terstruktur |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
|
Jendela Konteks |
Input: 200.000 Output: 100.000 |
Input: 200.000 Output: 100.000 |
Input: 200.000 Output: 100.000 |
Input: 200.000 Output: 100.000 |
Input: 200.000 Output: 100.000 |
Input: 200.000 Output: 100.000 |
|
Upaya penalaran |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
|
Input gambar |
✅ |
✅ |
✅ |
✅ |
- |
✅ |
| API Penyelesaian Chat |
- |
- |
✅ |
✅ |
✅ |
✅ |
| Respons API |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
| Fungsi/Alat |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
| Panggilan Alat Paralel |
- |
- |
- |
- |
- |
- |
max_completion_tokens
1 |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
| Pesan Sistem 2 |
✅ |
✅ |
✅ |
✅ |
✅ |
✅ |
|
Ringkasan penalaran |
✅ |
- |
✅ |
✅ |
- |
- |
| Streaming 3 |
✅ |
- |
✅ |
✅ |
✅ |
- |
1 Model penalaran hanya akan berfungsi dengan max_completion_tokens parameter ketika menggunakan API Chat Completions. Gunakan max_output_tokens dengan API Respons.
2 Model seri o* terbaru mendukung pesan sistem untuk mempermudah migrasi. Ketika Anda menggunakan pesan sistem dengan o4-mini, , o3o3-mini, dan o1 itu akan diperlakukan sebagai pesan pengembang. Anda tidak boleh menggunakan pesan pengembang dan pesan sistem dalam permintaan API yang sama.
3 Streaming hanya untuk o3 akses terbatas.
Catatan
- Untuk menghindari batas waktu, disarankan menggunakan mode latar belakang untuk
o3-pro.
-
o3-pro saat ini tidak mendukung pembuatan gambar.
Parameter yang tidak didukung
GPT-6 Astra tidak mendukung nilai temperature atau top_p kustom maupun probabilitas logaritmik (logprobs).
Model penalaran lainnya tidak mendukung parameter berikut:
-
temperature, top_p, presence_penalty, frequency_penalty, logprobs, top_logprobs, logit_bias, max_tokens
Hasil Markdown
Secara default o3-mini model dan o1 tidak akan mencoba menghasilkan output yang menyertakan pemformatan markdown. Kasus penggunaan umum di mana perilaku ini tidak diinginkan adalah ketika Anda ingin model menghasilkan kode yang terkandung dalam blok kode markdown. Saat model menghasilkan output tanpa pemformatan markdown, dalam pengalaman playground interaktif Anda kehilangan fitur seperti penyorotan sintaks dan blok kode yang dapat disalin. Untuk mengambil alih perilaku default baru ini dan mendorong penyertaan markdown dalam respons model, tambahkan string Formatting re-enabled ke awal pesan pengembang Anda.
Formatting re-enabled Menambahkan ke awal pesan pengembang Anda tidak menjamin bahwa model akan menyertakan pemformatan markdown dalam responsnya, itu hanya meningkatkan kemungkinan. Kami telah menemukan dari pengujian internal bahwa Formatting re-enabled kurang efektif dengan sendirinya pada model o1 dibandingkan dengan o3-mini.
Untuk meningkatkan performa Formatting re-enabled Anda dapat menambah lebih lanjut awal pesan pengembang yang akan sering menghasilkan output yang diinginkan. Daripada hanya menambahkan Formatting re-enabled ke awal pesan pengembang, Anda dapat bereksperimen dengan menambahkan instruksi awal yang lebih deskriptif seperti salah satu contoh di bawah ini:
Formatting re-enabled - please enclose code blocks with appropriate markdown tags.
Formatting re-enabled - code output should be wrapped in markdown.
Bergantung pada output yang diharapkan, Anda mungkin perlu menyesuaikan pesan pengembang awal Anda lebih lanjut untuk menargetkan kasus penggunaan spesifik Anda.