This API that uses function calling return an error with gpt-4-turbo but works with gpt-4-turbo-preview.
curl 'https://api.openai.com/v1/chat/completions' \
-H 'authorization: Bearer {API_KEY}' \
-H 'content-type: application/json' \
--data-raw $'{"model":"gpt-4-turbo","stream":true,"messages":[{"role":"system","content":"You are a helpful AI assistant. Today is Wed Apr 10 2024, local time is 06:55:33 GMT+0700 (Indochina Time)."},{"role":"user","content":"generate a cat image with stable diffusion"},{"role":"assistant","content":"","tool_calls":[{"index":0,"id":"call_iR04HNFR21yGXNqvUTro5Ra0","type":"function","function":{"name":"image_generation_via_stable_diffusion","arguments":"{\\"prompt\\":\\"A realistic depiction of a domestic cat sitting gracefully in a sunlit garden. The cat has a fluffy, well-groomed fur coat in shades of grey and white. It is sitting with its tail wrapped around its paws, and its eyes are bright and attentive. In the background, there are flowers and lush greenery, with light filtering through the leaves, creating a serene and picturesque scene. The overall atmosphere is calm and inviting, highlighting the beauty of an ordinary day in the life of a domestic cat.\\"}"}}]},{"role":"tool","content":"The images have been rendered and shown to the user.","tool_call_id":"call_iR04HNFR21yGXNqvUTro5Ra0","name":"image_generation_via_stable_diffusion"}],"tools":[{"type":"function","function":{"name":"image_generation_via_stable_diffusion","parameters":{"type":"object","required":["prompt"],"properties":{"prompt":{"type":"string","description":"The text description of the desired image."}}},"description":"Generate images using Stable Diffusion based on a text description. Adhere to guidelines such as English translation, not depicting politicians or recent artists, and ensuring artist references are over 100 years old.\\n\\nWhen creating prompt: substitute artist names with style-describing adjectives, include artistic era, mention primary medium. Image type, descent, gender are to be explicitly stated. Avoid offense and bias, conceal identities except gender and physique, retain text references, replace profession titles with universal terms.\\n\\nPrompt changes aren\'t allowed unless they anonymise individuals. Replace creative professional/studio names with style descriptions. All prompts should detail every image part in objective terms within a detailed paragraph of over three sentences.\\n\\nImportant: after calling this function, the output images will be shown to the user automatically. You don\'t need to include the output image to the users again in your response to avoid duplicate images."}}],"tool_choice":"auto"}'
The response:
{
"error": {
"message": "Unknown parameter: 'messages[2].tool_calls[0].index'.",
"type": "invalid_request_error",
"param": "messages[2].tool_calls[0].index",
"code": "unknown_parameter"
}
}
Here is the formatted JSON body for easier reading:
{
"messages": [
{
"content": "You are a helpful AI assistant. Today is Wed Apr 10 2024, local time is 06:55:33 GMT+0700 (Indochina Time).",
"role": "system"
},
{
"content": "generate a cat image with stable diffusion",
"role": "user"
},
{
"content": "",
"role": "assistant",
"tool_calls": [
{
"function": {
"arguments": "{\"prompt\":\"A realistic depiction of a domestic cat sitting gracefully in a sunlit garden. The cat has a fluffy, well-groomed fur coat in shades of grey and white. It is sitting with its tail wrapped around its paws, and its eyes are bright and attentive. In the background, there are flowers and lush greenery, with light filtering through the leaves, creating a serene and picturesque scene. The overall atmosphere is calm and inviting, highlighting the beauty of an ordinary day in the life of a domestic cat.\"}",
"name": "image_generation_via_stable_diffusion"
},
"id": "call_iR04HNFR21yGXNqvUTro5Ra0",
"index": 0,
"type": "function"
}
]
},
{
"content": "The images have been rendered and shown to the user.",
"name": "image_generation_via_stable_diffusion",
"role": "tool",
"tool_call_id": "call_iR04HNFR21yGXNqvUTro5Ra0"
}
],
"model": "gpt-4-turbo",
"stream": true,
"tool_choice": "auto",
"tools": [
{
"function": {
"description": "Generate images using Stable Diffusion based on a text description. Adhere to guidelines such as English translation, not depicting politicians or recent artists, and ensuring artist references are over 100 years old.\n\nWhen creating prompt: substitute artist names with style-describing adjectives, include artistic era, mention primary medium. Image type, descent, gender are to be explicitly stated. Avoid offense and bias, conceal identities except gender and physique, retain text references, replace profession titles with universal terms.\n\nPrompt changes aren't allowed unless they anonymise individuals. Replace creative professional/studio names with style descriptions. All prompts should detail every image part in objective terms within a detailed paragraph of over three sentences.\n\nImportant: after calling this function, the output images will be shown to the user automatically. You don't need to include the output image to the users again in your response to avoid duplicate images.",
"name": "image_generation_via_stable_diffusion",
"parameters": {
"properties": {
"prompt": {
"description": "The text description of the desired image.",
"type": "string"
}
},
"required": [
"prompt"
],
"type": "object"
}
},
"type": "function"
}
]
}