DevUI 提供相容的 OpenAI 回應 API,讓你能使用 OpenAI SDK 或任何 HTTP 客戶端與你的代理程式及工作流程互動。
即將推出
C# 的 DevUI 文件即將推出。 請稍後回來查看,或參考 Python 文件以獲得概念指引。
基礎 URL
http://localhost:8080/v1
埠可以用 CLI 選項來設定 --port 。
Authentication
預設情況下,DevUI 不要求本地開發認證。 當執行時 --auth,承載憑證認證是必要的。
使用 OpenAI SDK
基本請求
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:8080/v1",
api_key="not-needed" # API key not required for local DevUI
)
response = client.responses.create(
metadata={"entity_id": "weather_agent"}, # Your agent/workflow name
input="What's the weather in Seattle?"
)
# Extract text from response
print(response.output[0].content[0].text)
串流
response = client.responses.create(
metadata={"entity_id": "weather_agent"},
input="What's the weather in Seattle?",
stream=True
)
for event in response:
# Process streaming events
print(event)
多回合對話
多回合對話使用標準 OpenAI conversation 參數:
# Create a conversation
conversation = client.conversations.create(
metadata={"agent_id": "weather_agent"}
)
# First turn
response1 = client.responses.create(
metadata={"entity_id": "weather_agent"},
input="What's the weather in Seattle?",
conversation=conversation.id
)
# Follow-up turn (continues the conversation)
response2 = client.responses.create(
metadata={"entity_id": "weather_agent"},
input="How about tomorrow?",
conversation=conversation.id
)
DevUI 會自動取得對話的訊息歷史並傳給代理。
REST API 端點
回應 API(OpenAI 標準)
執行代理或工作流程:
curl -X POST http://localhost:8080/v1/responses \
-H "Content-Type: application/json" \
-d '{
"metadata": {"entity_id": "weather_agent"},
"input": "What is the weather in Seattle?"
}'
對話 API(OpenAI 標準)
| 端點 | 方法 | Description |
|---|---|---|
/v1/conversations |
郵件 | 建立對話 |
/v1/conversations/{id} |
GET | 獲取對話細節 |
/v1/conversations/{id} |
郵件 | 更新對話中繼資料 |
/v1/conversations/{id} |
刪除 | 刪除對話 |
/v1/conversations?agent_id={id} |
GET | 清單對話(DevUI 擴充功能) |
/v1/conversations/{id}/items |
郵件 | 將內容加入對話 |
/v1/conversations/{id}/items |
GET | 列出對話項目 |
/v1/conversations/{id}/items/{item_id} |
GET | 找個話題話題 |
實體管理(DevUI 擴充套件)
| 端點 | 方法 | Description |
|---|---|---|
/v1/entities |
GET | 列出已發現的代理/工作流程 |
/v1/entities/{entity_id}/info |
GET | 獲取詳細實體資訊 |
/v1/entities/{entity_id}/reload |
郵件 | 熱重載實體(開發者模式) |
健康情況檢查
curl http://localhost:8080/health
伺服器元資料
取得伺服器配置與功能:
curl http://localhost:8080/meta
退貨
-
ui_mode- 電流模式(developer或user) -
version- DevUI 版本 -
framework- 框架名稱(agent_framework) -
runtime- 後端執行時(python) -
capabilities- 功能標誌(追蹤、OpenAI 代理、部署) -
auth_required- 是否啟用認證
事件映射
DevUI 將代理框架事件映射到 OpenAI 回應 API 事件。 下表顯示了地圖:
生命週期事件
| OpenAI 活動 | 代理框架事件 |
|---|---|
response.created + response.in_progress |
AgentStartedEvent |
response.completed |
AgentCompletedEvent |
response.failed |
AgentFailedEvent |
response.created + response.in_progress |
WorkflowStartedEvent |
response.completed |
WorkflowCompletedEvent |
response.failed |
WorkflowFailedEvent |
內容類型
| OpenAI 活動 | 代理框架內容 |
|---|---|
response.content_part.added + response.output_text.delta |
TextContent |
response.reasoning_text.delta |
TextReasoningContent |
response.output_item.added |
FunctionCallContent (首字母) |
response.function_call_arguments.delta |
FunctionCallContent (三叉戟) |
response.function_result.complete |
FunctionResultContent |
response.output_item.added (圖片) |
DataContent (圖片) |
response.output_item.added (檔案) |
DataContent (檔案) |
error |
ErrorContent |
工作流程事件
| OpenAI 活動 | 代理框架事件 |
|---|---|
response.output_item.added (執行者行動項目) |
包含 WorkflowEvent 的 type="executor_invoked" |
response.output_item.done (執行者行動項目) |
包含 WorkflowEvent 的 type="executor_completed" |
response.output_item.added (回應輸出訊息) |
包含 WorkflowEvent 的 type="output" |
DevUI 自訂擴充套件
DevUI 為 Agent Framework 特定功能新增自訂事件類型:
-
response.function_approval.requested- 函式核准請求 -
response.function_approval.responded- 功能核准回應 -
response.function_result.complete- 伺服器端函數執行結果 -
response.workflow_event.complete- 工作流程事件 -
response.trace.complete- 執行軌跡
這些自訂擴充功能有命名空間,標準 OpenAI 用戶端可以安全忽略。
OpenAI 代理模式
DevUI 提供 OpenAI 代理 功能,可直接透過介面測試 OpenAI 模型,無需建立自訂代理。 透過介面中的設定啟用。
curl -X POST http://localhost:8080/v1/responses \
-H "X-Proxy-Backend: openai" \
-d '{"model": "gpt-4.1-mini", "input": "Hello"}'
備註
代理模式需要 OPENAI_API_KEY 在後端設定環境變數。