OpenAI GPT-4o (Aug '24)

August 2024 update of the GPT-4o model, enhancing performance and accuracy

Creator: OpenAILicense: Proprietary

Summary

Artificial Analysis Quality
Index
77
Output Speed (Tokens per
Second)
83
Model Pricing (USD per 1M Tokens)
$4.400
Latency (to receive the first
token)
14.21s
Context Window (tokens)
128k

Comparison with other models

Quality

Artificial Analysis Quality Index; Higher is better

+ Add model

Speed

Output Tokens per Second; Higher is better

+ Add model

Pricing

USD per 1M Tokens; Lower is better

+ Add model

Latency

Seconds to First Tokens Chunk Received; Lower is better

+ Add model

Authentication

API keys

The OpenAI API uses API keys for authentication. You can create API keys at a user or service account level. Service accounts are tied to a "bot" individual and should be used to provision access for production systems. Each API key can be scoped to one of the following,

  1. Project keys - Provides access to a single project (preferred option); access Project API keys by selecting the specific project you wish to generate keys against.
  2. User keys - Our legacy keys. Provides access to all organizations and all projects that user has been added to; access API Keys to view your available keys. We highly advise transitioning to project keys for best security practices, although access via this method is currently still supported.
1 Authorization: Bearer OPENAI_API_KEY

Organizations and projects (optional)

For users who belong to multiple organizations or are accessing their projects through their legacy user API key, you can pass a header to specify which organization and project is used for an API request. Usage from these API requests will count as usage for the specified organization and project.

To access the Default project in an organization, leave out the OpenAI-Project header

Example curl command:

1 2 3 4 curl https://api.openai.com/v1/models \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "OpenAI-Organization: YOUR_ORG_ID" \ -H "OpenAI-Project: $PROJECT_ID"

Example with the `openai` Python package:

1 2 3 4 5 6 from openai import OpenAI client = OpenAI( organization='YOUR_ORG_ID', project='$PROJECT_ID', )

Example with the `openai` Node.js package:

1 2 3 4 5 6 import OpenAI from "openai"; const openai = new OpenAI({ organization: "YOUR_ORG_ID", project: "$PROJECT_ID", });

Organization IDs can be found on your Organization settings page. Project IDs can be found on your General settings page by selecting the specific project.

Create chat completion

POSThttps://api.openai.com/v1/chat/completions

Generate AI responses for conversations using text, images, and audio.

Request body

messages array *Required

The conversation history as a series of messages. Supports various formats including text, images, and audio based on model capabilities.

model string *Required

The specific model to be used for generating responses. Check compatibility guide for available models.

store boolean *Optional

Choose whether to save this chat for model improvement purposes. Default is false.

frequency_penalty number *Optional

Adjust from -2 to 2 to control repetition. Positive values reduce word repetition. Default is 0.

presence_penalty number *Optional

Set between -2 and 2 to influence topic variety. Positive values encourage new topics. Default is 0.

temperature number *Optional

Controls response randomness (0-2). Higher for more creative, lower for more focused replies. Default is 1.

top_p number *Optional

Alternative to temperature. Sets probability threshold for token selection. Example: 0.1 means top 10% probable tokens. Default is 1.

stream boolean *Optional

Enable real-time response streaming, similar to ChatGPT. Default is false.

response_format object *Optional

Specify output format. Supports JSON structure for formatted responses. Available on newer models.

seed integer *Optional

Set for consistent responses across multiple calls. Results may still vary slightly.

user string *Optional

Unique identifier for tracking end-user interactions and monitoring system usage.

curl https://api.openai.com/v1/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer $OPENAI_API_KEY" -d '{ "model": "gpt-4o", "messages": [ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Hello!" } ] }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 { "id": "chatcmpl-123", "object": "chat.completion", "created": 1677652288, "model": "gpt-4o-mini", "system_fingerprint": "fp_44709d6fcb", "choices": [{ "index": 0, "message": { "role": "assistant", "content": " Hello there, how may I assist you today?", }, "logprobs": null, "finish_reason": "stop" }], "usage": { "prompt_tokens": 9, "completion_tokens": 12, "total_tokens": 21, "completion_tokens_details": { "reasoning_tokens": 0, "accepted_prediction_tokens": 0, "rejected_prediction_tokens": 0 } } }