curl命令行直接访问openai
curl --location --request POST 'https://api.openai.com/v1/chat/completions' \
--header 'Authorization: SK-xxx' \
--header 'content-type: application/json' \
--header 'Accept: */*' \
--data-raw '{
"model": "gpt-4o",
"messages": [
{
"role": "system",
"content": "Say Hello!"
}
],
"stream": true,
"temperature": 1,
"max_tokens": 10
}'
curl访问azure openai
# 参考 https://learn.microsoft.com/en-us/azure/ai-services/openai/reference
curl --location --request POST 'https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/chat/completions?api-version=2024-06-01' \
--header 'api-key: SK-xxxx' \
--header 'content-type: application/json' \
--header 'Accept: */*' \
--header 'Connection: keep-alive' \
--data-raw '{
"messages": [
{
"content": "你是一个相声演员,擅长将郭德纲的相声",
"role": "system"
},
{
"content": [
{
"text": "Tell me a joke",
"type": "text"
}
],
"role": "user"
}
],
"temperature": 0.7,
"stream": false,
"model": "YOUR_RESOURCE_NAME"
}'
沪公网安备 31011502001064号