Làm chủ các tham số phản hồi

Làm việc với OpenAI Responses API

James Chapman

AI Curriculum Manager, DataCamp

Chọn mô hình

response = client.responses.create(
    model="gpt-5.4-mini",
    input="What is recursion?",
)
1 https://platform.openai.com/docs/models
Làm việc với OpenAI Responses API

Chọn mô hình

response = client.responses.create(
    model="gpt-5.4-mini",
    input="What is recursion?",
)
  • Quy tắc ngón tay cái: dùng mô hình rẻ nhất đáp ứng các yêu cầu khác
Model Tốc độ Chi phí Phù hợp nhất cho
gpt-5.4-mini Nhanh Thấp Nhiệm vụ đơn giản, Hỏi-đáp
gpt-5.5 Vừa Cao hơn Lập luận phức tạp
1 https://platform.openai.com/docs/models
Làm việc với OpenAI Responses API

LLM và Token

  • Token: đơn vị văn bản giúp AI hiểu và diễn giải văn bản

$$

Câu "How can the OpenAI API deliver business value?" với mỗi token được tô màu khác nhau.

1 https://platform.openai.com/tokenizer
Làm việc với OpenAI Responses API

LLM và Token

 

  • LLM không lập luận: tạo các token có xác suất cao nhất theo sau prompt

non_reasoning_output.gif

Làm việc với OpenAI Responses API

LLM và Token

reasoning_output.gif

Làm việc với OpenAI Responses API

Mức độ lập luận

response = client.responses.create(
    model="gpt-5.4-mini",
    input="Explain LLMs to a 6yr old.",

reasoning={"effort": "none"}
)
Làm việc với OpenAI Responses API

Mức độ lập luận

response = client.responses.create(
    model="gpt-5.4-mini",
    input="Explain LLMs to a 6yr old.",
    reasoning={"effort": "none"}
)
Effort Phù hợp nhất cho
none Nhiệm vụ tầm thường hoặc máy móc.
low Nhiệm vụ đơn giản, ưu tiên tốc độ và chi phí.
medium Mặc định: cân bằng lập luận và hiệu quả.
high Nhiệm vụ phức tạp, nhiều bước, nặng logic.
xhigh Khó nhất, đẩy giới hạn khả năng hiện có
Làm việc với OpenAI Responses API

Tóm tắt lập luận

response = client.responses.create(
    model="gpt-5.4-mini",
    input="Explain LLMs to a 6yr old.",
    reasoning={
        "effort": "medium",

"summary": "auto"
} )
Làm việc với OpenAI Responses API

Giới hạn số token đầu ra

response = client.responses.create(
    model="gpt-5.4-mini",
    input="Explain LLMs to a 6yr old.",
    reasoning={"effort": "none"},

max_output_tokens=500
)
  • max_output_tokens bao gồm cả reasoning tokens
Làm việc với OpenAI Responses API

Tóm tắt

  • Nhiệm vụ đơn giản → bắt đầu với mô hình nhỏ, không lập luận, và ít token
  • Nhiệm vụ phức tạp → bắt đầu với mô hình cỡ trung và có lập luận, rồi tinh chỉnh

parameter_link.jpg

Làm việc với OpenAI Responses API

Cùng luyện tập nào!

Làm việc với OpenAI Responses API

Preparing Video For Download...