The error you’re encountering (tools[0].function.name: string too long. Expected a string with maximum length 64
) occurs because the operationId
in your OpenAPI specification exceeds 64 characters.
The operationId
is automatically derived from the name
in the OpenAPI spec and must be 64 characters or fewer.
For example, the following operationId
is too long:
"operationId": "create_assistant_with_tools_endpoint_api_v2_assistant_create_with_tools_post"
Here’s the relevant example of the OpenAPI specification:
"/api/v2/assistant/create_with_tools": {
"post": {
"tags": [
"Assistants V2"
],
"summary": "Create Assistant With Tools Endpoint",
"operationId": "create_assistant_with_tools_endpoint_api_v2_assistant_create_with_tools_post",
"parameters": [
{
"name": "openai_api_key",
"in": "query",
"required": false,
"schema": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"description": "Optional OpenAI API key",
"title": "Openai Api Key"
},
"description": "Optional OpenAI API key"
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateAssistantWithToolsRequest"
}
}
}
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Assistant"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
}
To resolve this, if you’re using FastAPI to define your API routers, you can set a shorter operation_id
in the route definition like this:
@router_assistant.post("/create_assistant", operation_id="create_assistant")
This will keep the operationId
within the 64-character limit, eliminating the error.