Create assistant
Create an assistant with a model and instructions.
Request body
modelstring
ID of the model to use. You can use the List models API to see all of your available models, or see our Model overview for descriptions of them.
modelstringRequired
modelstringRequired
gpt-4.1string
gpt-4.1-ministring
gpt-4.1-nanostring
gpt-4.1-2025-04-14string
gpt-4.1-mini-2025-04-14string
gpt-4.1-nano-2025-04-14string
o3-ministring
o3-mini-2025-01-31string
o1string
o1-2024-12-17string
gpt-4ostring
gpt-4o-2024-11-20string
gpt-4o-2024-08-06string
gpt-4o-2024-05-13string
gpt-4o-ministring
gpt-4o-mini-2024-07-18string
gpt-4.5-previewstring
gpt-4.5-preview-2025-02-27string
gpt-4-turbostring
gpt-4-turbo-2024-04-09string
gpt-4-0125-previewstring
gpt-4-turbo-previewstring
gpt-4-1106-previewstring
gpt-4-vision-previewstring
gpt-4string
gpt-4-0314string
gpt-4-0613string
gpt-4-32kstring
gpt-4-32k-0314string
gpt-4-32k-0613string
gpt-3.5-turbostring
gpt-3.5-turbo-16kstring
gpt-3.5-turbo-0613string
gpt-3.5-turbo-1106string
gpt-3.5-turbo-0125string
gpt-3.5-turbo-16k-0613string
namestring or null
The name of the assistant. The maximum length is 256 characters.descriptionstring or null
The description of the assistant. The maximum length is 512 characters.instructionsstring or null
The system instructions that the assistant uses. The maximum length is 256,000 characters.reasoning_effortstring or nullDefaults: medium
o-series models only
Constrains effort on reasoning for reasoning models. Currently supported values are
low,medium, andhigh. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.lowstring
mediumstring
highstring
toolsarrayDefaults:
A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types
code_interpreter,file_search, orfunction.Code interpreter toolobject
typestringRequired
The type of tool being defined:
code_interpretercode_interpreterstring
FileSearch toolobject
typestringRequired
The type of tool being defined:
file_searchfile_searchstring
file_searchobject
Overrides for the file search tool.max_num_resultsinteger
The maximum number of results the file search tool should output. The default is 20 for
gpt-4*models and 5 forgpt-3.5-turbo. This number should be between 1 and 50 inclusive.Note that the file search tool may output fewer than
max_num_resultsresults. See the file search tool documentation for more information.ranking_optionsobject
The ranking options for the file search. If not specified, the file search tool will use the
autoranker and a score_threshold of 0.See the file search tool documentation for more information.
rankerstring
The ranker to use for the file search. If not specified will use the
autoranker.autostring
default_2024_08_21string
score_thresholdnumberRequired
The score threshold for the file search. All values must be a floating point number between 0 and 1.
Function toolobject
typestringRequired
The type of tool being defined:
functionfunctionstring
functionobjectRequired
descriptionstring
A description of what the function does, used by the model to choose when and how to call the function.namestringRequired
The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.parametersobject
The parameters the functions accepts, described as a JSON Schema object. See the guide for examples, and the JSON Schema reference for documentation about the format.
Omitting
parametersdefines a function with an empty parameter list.strictboolean or nullDefaults: false
Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the
parametersfield. Only a subset of JSON Schema is supported whenstrictistrue. Learn more about Structured Outputs in the .
tool_resourcesobject or null
A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the
code_interpretertool requires a list of file IDs, while thefile_searchtool requires a list of vector store IDs.code_interpreterobject
file_idsarrayDefaults:
A list of file IDs made available to the
code_interpretertool. There can be a maximum of 20 files associated with the tool.itemsstring
file_searchobject
file_searchobject
file_searchobject
metadataobject or null
Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.temperaturenumber or nullDefaults: 1
What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.top_pnumber or nullDefaults: 1
An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both.response_formatstring or object
Specifies the format that the model must output. Compatible with GPT-4o, GPT-4 Turbo, and all GPT-3.5 Turbo models since
gpt-3.5-turbo-1106.Setting to
enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the Structured Outputs guide.Setting to
enables JSON mode, which ensures the message the model generates is valid JSON.Important: when using JSON mode, you must also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if
finish_reason="length", which indicates the generation exceededmax_tokensor the conversation exceeded the max context length.response_formatstring
autois the default valueautostring
Textobject
Default response format. Used to generate text responses.typestringRequired
The type of response format being defined. Always
text.textstring
JSON objectobject
JSON object response format. An older method of generating JSON responses. Using
json_schemais recommended for models that support it. Note that the model will not generate JSON without a system or user message instructing it to do so.typestringRequired
The type of response format being defined. Always
json_object.json_objectstring
JSON schemaobject
JSON Schema response format. Used to generate structured JSON responses. Learn more about Structured Outputs.
typestringRequired
The type of response format being defined. Always
json_schema.json_schemastring
json_schemaobjectRequired
Structured Outputs configuration options, including a JSON Schema.descriptionstring
A description of what the response format is for, used by the model to determine how to respond in the format.namestringRequired
The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.schemaobject
The schema for the response format, described as a JSON Schema object. Learn how to build JSON schemas here.
strictboolean or nullDefaults: false
Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the
schemafield. Only a subset of JSON Schema is supported whenstrictistrue. To learn more, read the Structured Outputs guide.
Response
An assistant object.
1 curl "https://api.openai.com/v1/assistants" \2 -H "Content-Type: application/json" \3 -H "Authorization: Bearer $OPENAI_API_KEY" \4 -H "OpenAI-Beta: assistants=v2" \5 -d '{6 "instructions": "You are a personal math tutor. When asked a question, write and run Python code to answer the question.",7 "name": "Math Tutor",8 "tools": [{"type": "code_interpreter"}],9 "model": "gpt-4o"10 }'
1 {2 "id": "asst_abc123",3 "object": "assistant",4 "created_at": 1698984975,5 "name": "Math Tutor",6 "description": null,7 "model": "gpt-4o",8 "instructions": "You are a personal math tutor. When asked a question, write and run Python code to answer the question.",9 "tools": [10 {11 "type": "code_interpreter"12 }13 ],14 "metadata": {},15 "top_p": 1.0,16 "temperature": 1.0,17 "response_format": "auto"18 }