- Get started
- Introduction
- Authentication
- Making requests
- Streaming
- Audio
- Batch
- Models
- Invites
- Chat
- Users
- Projects
- Project users
- Project service accounts
- Project API keys
- Audit logs
- Usage
- Project rate limits
- Completions
- Uploads
- Embeddings
- Files
- Moderations
- Assistants (v1)
- Threads (v1)
- Messages (v1)
- Runs (v1)
- Images
- Fine-tuning
Create thread and run (v1)
POST
https://api.openai.com/v1/threads/runs
Request
Authorization
Provide your bearer token in the
Authorization
header when making requests to protected resources.Example:
Authorization: Bearer ********************
Header Params
Authorization
stringÂ
required
Example:
Bearer $OPENAI_API_KEY
Content-Type
stringÂ
required
Example:
application/json
OpenAI-Beta
stringÂ
required
Example:
assistants=v1
Body Params application/json
Example
{
"assistant_id": "asst_abc123",
"thread": {
"messages": [
{
"role": "user",
"content": "Explain deep learning to a 5 year old."
}
]
}
}
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 'https://api.openai.com/v1/threads/runs' \
--header 'Authorization: Bearer $OPENAI_API_KEY' \
--header 'OpenAI-Beta: assistants=v1' \
--header 'Content-Type: application/json' \
--data-raw '{
"assistant_id": "asst_abc123",
"thread": {
"messages": [
{"role": "user", "content": "Explain deep learning to a 5 year old."}
]
}
}'
Responses
🟢200Success
application/json
Body
id
stringÂ
required
object
stringÂ
required
created_at
integerÂ
required
assistant_id
stringÂ
required
thread_id
stringÂ
required
status
stringÂ
required
started_at
nullÂ
required
expires_at
integerÂ
required
cancelled_at
nullÂ
required
failed_at
nullÂ
required
completed_at
nullÂ
required
last_error
nullÂ
required
model
stringÂ
required
instructions
stringÂ
required
tools
array[string]
required
file_ids
array[string]
required
metadata
objectÂ
required
usage
nullÂ
required
temperature
integerÂ
required
Example
{
"id": "run_abc123",
"object": "thread.run",
"created_at": 1699076792,
"assistant_id": "asst_abc123",
"thread_id": "thread_abc123",
"status": "queued",
"started_at": null,
"expires_at": 1699077392,
"cancelled_at": null,
"failed_at": null,
"completed_at": null,
"last_error": null,
"model": "gpt-4-turbo",
"instructions": "You are a helpful assistant.",
"tools": [],
"file_ids": [],
"metadata": {},
"usage": null,
"temperature": 1
}
Modified at 2024-12-13 10:20:37