{"model":"gpt-4o","messages":[{"role":"developer","content":"You are a helpful assistant."},{"role":"user","content":"Write a haiku about recursion in programming."}]}
示例代码
Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl--location--request POST 'https://api.openai.com/v1/chat/completions' \
--header'Authorization: Bearer sk-' \
--header'Content-Type: application/json' \
--data-raw'{
"model": "gpt-4o",
"messages": [
{
"role": "developer",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Write a haiku about recursion in programming."
}
]
}'