- Introduction
- Quick Start Guide
- Make a request
- Chat Models
- ChatGpt
- ChatGPT (Audio)
- ChatGPT (Chat)
- Chat completion object
- Create chat completion (streaming)
- Create chat completion (non-streaming)
- Create chat image recognition (streaming)
- Create chat image recognition (streaming) base64
- Create chat image recognition (non-streaming)
- Function calling
- N choices
- Create chat function call (only non-streaming)
- Create structured output
- ChatGPT (Completions)
- ChatGPT(Embeddings)
- Anthropic Claude
- Gemini
- Image Models
- GPT-IMAGE-1
- MJ
- Ideogram
- Kling Image
- Flux
- Recraft API
- Models use Dall-e Format
- DALL·E 3POST
- Video Models
- Kling Video
- Runway ML Video
- Luma Video
- Pika Video
- Google Veo
- Minimax - Hailuo
- Music Model - Suno
- Python Samples
- python openai official library (using AutoGPT, langchain, etc.)
- Python uses speech to text
- Python uses text to speech
- Python uses Embeddings
- python calls DALL·E
- python simple call openai function-calling demo
- python langchain
- python llama_index
- Python uses gpt-4o to identify pictures-local pictures
- python library streaming output
- Python uses gpt-4o to identify images
- Plug-in/software usage tutorials
- Help Center
- Tutorials
Messages(function call)
POST
/v1/messages
Request
Header Params
Authorization
string
optional
Body Params application/json
model
string
required
max_tokens
integer
required
tools
array [object {3}]
required
name
string
optional
description
string
optional
input_schema
object
optional
messages
array [object {2}]
required
role
string
optional
content
string
optional
Example
{
"model": "claude-sonnet-4-20250514",
"max_tokens": 1024,
"tools": [
{
"name": "get_weather",
"description": "Get the current weather in a given location",
"input_schema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
}
},
"required": [
"location"
]
}
}
],
"messages": [
{
"role": "user",
"content": "What is the weather like in San Francisco?"
}
]
}
Request samples
Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
Request Request Example
Shell
JavaScript
Java
Swift
curl --location --request POST '/v1/messages' \
--header 'Authorization;' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "claude-sonnet-4-20250514",
"max_tokens": 1024,
"tools": [
{
"name": "get_weather",
"description": "Get the current weather in a given location",
"input_schema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
}
},
"required": [
"location"
]
}
}
],
"messages": [
{
"role": "user",
"content": "What is the weather like in San Francisco?"
}
]
}'
Responses
🟢200OK
application/json
Body
id
string
required
type
string
required
role
string
required
content
array [object {2}]
required
type
string
optional
text
string
optional
stop_reason
string
required
model
string
required
usage
object
required
input_tokens
integer
required
cache_creation_input_tokens
integer
required
cache_read_input_tokens
integer
required
output_tokens
integer
required
Example
{
"id": "chatcmpl-89D7UVB9Lac3rIZD7Wgt69AT33Njf",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": " I don't see any image in your message. Could you please upload or share the image you'd like me to describe? Once you do, I'll be happy to provide a detailed description of what I see."
}
],
"stop_reason": "end_turn",
"model": "claude-sonnet-4-20250514",
"usage": {
"input_tokens": 96,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"output_tokens": 43
}
}
Modified at 2025-06-13 15:23:00