#API usage reporting with images

1 messages · Page 1 of 1 (latest)

solemn parrot
#

ChatGPT shared link: (optional)

Steps to reproduce:

  1. Use the chat completions endpoint with an image included at low detail. For example, this curl command (copied from OpenAI docs, but with low detail enabled):
curl https://api.openai.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "What’s in this image?"
          },
          {
            "type": "image_url",
            "image_url": {
              "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
              "detail": "low"
            }
          }
        ]
      }
    ],
    "max_tokens": 300
  }'

Expected result:

  1. The fields in the usage field in the response should reflect a token usage of roughly 100 tokens (85 for the image + whatever's in the other messages).

Actual result:

  1. The fields in the usage field are quite high (roughly 3K tokens)
{
  "id": "XXX",
  "object": "chat.completion",
  "created": 1722454358,
  "model": "gpt-4o-mini-2024-07-18",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "The image depicts a serene landscape featuring a wooden boardwalk that stretches through lush green grass and vegetation. The sky is expansive with scattered clouds, suggesting a pleasant day. The scene evokes a sense of tranquility and connection to nature."
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 2846,
    "completion_tokens": 45,
    "total_tokens": 2891
  },
  "system_fingerprint": "XXX"
}

Additional information

N/A