0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

OpenAI APIを使用した簡単なリクエストのPHPコード chatGPT

Posted at

<?php

$apiKey = 'APIキー';
$endpoint = 'https://api.openai.com/v1/chat/completions';

$headers = array(
    'Content-Type: application/json',
    'Authorization: Bearer ' . $apiKey
);

$user_question = isset($_POST['user_question_s']) ? $_POST['user_question_s'] : '';

$article = array(
    'model' => 'gpt-3.5-turbo',
    'messages' => [
        [
            'role' => 'system',
            'content' => '口コミで使える文章を口コミと言う言葉を使わずに50文字の日本語で考えて'
        ],
        [
            'role' => 'user',
            'content' => $user_question
        ]
    ],
    'max_tokens' => 100
);
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?