Open AIのAPI
Tag:AI
GPT3の設定
1 2 3 4 5 6 7 8 9 |
curl https://api.openai.com/v1/completions -H "Authorization: Bearer $OPENAI_API_KEY" -H "Content-Type: application/json" -d '{ "model": "text-davinci-003", "max_tokens": 1024, "temperature": 0.9, "prompt": "日本の首都は" }' |
戻り値(JSON)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
{ "id": "cmpl-2pUj71DCTB0V9HZAlzaVFCYNHK2K9", "object": "text_completion", "created": 1677730861, "model": "text-davinci-003", "choices": [ { "text": "東京です", "index": 0, "logprobs": null, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 10, "completion_tokens": 16, "total_tokens": 26 } } |
ChatGPTの設定
1 2 3 4 5 6 7 |
curl https://api.openai.com/v1/chat/completions //chatを追加 -H "Authorization: Bearer $OPENAI_API_KEY" -H "Content-Type: application/json" -d '{ "model": "gpt-3.5-turbo", //モデルを指定 "messages": [{"role": "user", "content": "What is the OpenAI mission?"}] //プロンプトが分かれる }' |
戻り値(JSON)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
{ "id": "chatcmpl-6pUSVvku6mgQ3V14yKOsoDZfxJL6s", "object": "chat.completion", "created": 1677730141, "model": "gpt-3.5-turbo-0301", "choices": [ { "message": { "role": "assistant", "content": "そうですねありがとうございます。" }, "finish_reason": "stop", "index": 0 } ], "usage": { "prompt_tokens": 309, "completion_tokens": 379, "total_tokens": 688 } } |
エラーの場合
1 2 3 4 5 6 |
{"error"=>{ "message": "Unrecognized request argument supplied: maxkens", "type": "invalid_request_error", "param": "", "code": "" }} |
料金表
input cost (1k) | output cost (1k) | max token | data | release | |
gpt-4o | |||||
gpt-4o-2024-05-13 | $0.005 | $0.015 | 128,000 | 2023.11 | 2024.05.13 |
gpt-4o-mini | |||||
gpt-4o-mini-2024-07-18 | $0.00015 | $0.0006 | 128,000 | 2023.11 | 2024.07.19 |
gpt-4-turbo-2024-04-09 | $0.01 | $0.03 | 128,000 | 2023.11 | |
gpt-4-0125-preview | $0.01 | $0.03 | 128,000 | 2023.11 | |
gpt-4-1106-preview | $0.01 | $0.03 | 128,000 | 2023.11 | |
gpt-4-vision-preview | $0.01 | $0.03 | 128,000 | 2023.11 | |
gpt-4 | gpt-4-0613を使用 | ||||
gpt-4-32k-0613 | $0.06 | $0.12 | 32,768 | 2023.06 | |
gpt-4-32k-0613 | $0.06 | $0.12 | 32,768 | 2023.06 | |
gpt-4-0613 | $0.03 | $0.06 | 8,192 | 2023.06 | |
gpt-4-32k | $0.12 | $0.12 | 32,768 | 2023.03 | |
gpt-4-0314 | $0.03 | $0.03 | 8,192 | 2023.03 | |
gpt-3.5-turbo | gpt-3.5-turbo-0613を使用 | ||||
gpt-3.5-turbo-0125 | $0.0005 | $0.0015 | 16,384 | 2021.09 | |
gpt-3.5-turbo-16k-0613 | $0.003 | $0.004 | 16,384 | 2021.09 | |
gpt-3.5-turbo-0613 | $0.0015 | $0.002 | 4,096 | 2021.09 | |
gpt-3.5-turbo-16k | $0.003 | $0.004 | 16,384 | 2021.09 | |
gpt-3.5-turbo-0301 | $0.002 | $0.002 | 4,096 | 2021.09 |
別のAI
Anthropic
input cost (1k) | output cost (1k) | max token | data | release | |
Claude 3.5 Opus | 2024後半 | ||||
Claude 3.5 Sonnet | $0.003 | $0.015 | 2024.04 | 2024.06.20 | |
Claude 3.5 Haiku | 2024後半 | ||||
Claude 3 Opus | $0.015 | $0.075 | 200,000 | 2023.08 | 2024.03.04 |
Claude 3 Sonnet | $0.003 | $0.015 | 200,000 | 2023.08 | 2024.03.04 |
Claude 3 Haiku | $0.00025 | $0.00125 | 200,000 | 2023.08 | 2024.03.04 |
Claude 2.1 | $0.008 | $0.024 | 200,000 | 2023.11.21 | |
Claude 2.0 | $0.008 | $0.024 | 100,000 | 2023.07.11 | |
Claude Instant | $0.0008 | $0.0024 | 100,000 | ||
Google (1000文字あたり)
input cost (1k) | output cost (1k) | max token | data | release | |
Gemini Ultra | 未リリース | ||||
Gemini 1.5 Pro | $0.0035 | $0.0105 | ~128,000 | 2024.05.30 | |
Gemini 1.5 Pro | $0.007 | $0.021 | 128,000~ | 2024.05.30 | |
Gemini 1.5 Flash | $0.00035 | $0.00053 | ~128,000 | 2024.05.30 | |
Gemini 1.5 Flash | $0.0007 | $0.00105 | 128,000~ | 2024.05.30 | |
Gemini 1.0 Pro | $0.0005 | $0.0015 | 2023.12.13 | ||
Gemini 1.0 Pro画像1枚 | $0.0025 | 2023.12.13 | |||
Gemini Nano | 未リリース |