Repository navigation
LLM Usage "picture_description_api" #4119
Replies: 3 comments
|
Hi @hajaraniwana! I'm Dosu and I'm helping the IBM Docling team.
1. Does it support returning usage information? 2. Where to access the usage information? usage = picture.meta.description.get_custom_part()["docling__usage"]Internally, the namespace 3. How does the capture work / how to customize? PictureDescriptionApiOptions(
url="https://your-api/v1/chat/completions",
usage_response_key="meta.usage", # or wherever your API puts it
...
)4. Is there an example implementation? To get this working, make sure:
Once on the correct version, the usage won't appear in the plain To reply, just mention @dosu. Share context across your team and agents. Try Dosu. |
|
Usage is captured, but it is not on the usage = picture.meta.description.get_custom_part()["docling__usage"]A JSON print that only shows Checklist:
Runnable example: If you are already on a post-#3632 release and |
|
Your install most likely predates the feature. Usage capture (#3632, merged 2026-06-22) first shipped in docling v2.105.0. Your The replies above are right that the usage lands under If it is still missing after the upgrade, |
Uh oh!
There was an error while loading. Please reload this page.
Unable to Get LLM Usage from
picture_description_apiHi , I have a problem when trying to get LLM usage/token usage from the API used by Docling's
picture_description_api.I am using
picture_description_apito generate descriptions for images. The image description itself is generated successfully, and I receive a response like this:{ "meta": { "summary": null, "description": { "confidence": null, "created_by": "not-implemented", "text": "The image features a cute, cartoon-style duck with a bright orange head and large, shiny black eyes. It has a small tuft of feathers on top of its head and an orange beak. The duck is holding a white piece of paper with black lines representing text, as if it is reading or presenting something. Its orange arms are wrapped around the paper. The duck is centered within a thick black circular border, creating a logo-like appearance. The overall style is simple, colorful, and friendly." }, "classification": null, "molecule": null, "tabular_chart": null, "code": null } }The image description is generated correctly, but I cannot find any information about the LLM usage, such as:
prompt_tokenscompletion_tokenstotal_tokensFor example, when I call my LLM API directly, I receive usage information such as:
{ "usage": { "prompt_tokens": 415, "completion_tokens": 619, "total_tokens": 1034 } }However, when the LLM is called through
picture_description_api, this usage information does not appear to be exposed in the resulting Docling document metadata.My questions
picture_description_apicurrently support returning or exposing LLM usage/token information?PictureDescriptionData/ picture metadata?picture_description_apithat preserves the LLM usage information?I am using a custom LLM API that is compatible with the OpenAI API format, and the API response contains the
usagefield correctly when called directly.Thanks!
All reactions