php调用Azure OpenAI的gpt4o大模型api示例代码

代码语言:php

所属分类:其他

代码描述:php调用Azure OpenAI的gpt4o大模型api示例代码

代码标签: php 调用 Azure OpenAI gpt4o 大模型 api 示例 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<?php
//申请AZURE_OPENAI教程:https://blog.bfw.wiki/biji_17223307740303670094.html
// 设置Azure OpenAI的端点和API密钥
$AZURE_OPENAI_ENDPOINT = '';
$AZURE_OPENAI_API_KEY = '';

// 设置请求的URL
$url = $AZURE_OPENAI_ENDPOINT . '/openai/deployments/gpt4o/chat/completions?api-version=2023-03-15-preview';
//
// 设置请求体
$data = [
    'messages' => [
        ['role' => 'system', 'content' => 'You are a helpful assistant.'],
        ['role' => 'user', 'content' => 'Does Azure OpenAI support customer managed keys?'],
        ['role' => 'assistant', 'content' => 'Yes, customer managed keys are supported by Azure OpenAI.'],
        ['role' => 'user', 'content' => 'Do other .........完整代码请登录后点击上方下载按钮下载查看

网友评论0