_count_image_tokens() — langchain Function Reference
Architecture documentation for the _count_image_tokens() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 7cf4873b_bc13_276a_ae3d_52fa0c9a42ef["_count_image_tokens()"] 2b046911_ea21_8e2e_ba0d_9d03da8d7bda["base.py"] 7cf4873b_bc13_276a_ae3d_52fa0c9a42ef -->|defined in| 2b046911_ea21_8e2e_ba0d_9d03da8d7bda 3d7b9c9e_fae0_940a_5e96_75a84e2ad11c["get_num_tokens_from_messages()"] 3d7b9c9e_fae0_940a_5e96_75a84e2ad11c -->|calls| 7cf4873b_bc13_276a_ae3d_52fa0c9a42ef d9f589e8_b1c5_45d1_92a1_362c97de0d6e["_resize()"] 7cf4873b_bc13_276a_ae3d_52fa0c9a42ef -->|calls| d9f589e8_b1c5_45d1_92a1_362c97de0d6e style 7cf4873b_bc13_276a_ae3d_52fa0c9a42ef fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/openai/langchain_openai/chat_models/base.py lines 3600–3605
def _count_image_tokens(width: int, height: int) -> int:
# Reference: https://platform.openai.com/docs/guides/vision/calculating-costs
width, height = _resize(width, height)
h = ceil(height / 512)
w = ceil(width / 512)
return (170 * h * w) + 85
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does _count_image_tokens() do?
_count_image_tokens() is a function in the langchain codebase, defined in libs/partners/openai/langchain_openai/chat_models/base.py.
Where is _count_image_tokens() defined?
_count_image_tokens() is defined in libs/partners/openai/langchain_openai/chat_models/base.py at line 3600.
What does _count_image_tokens() call?
_count_image_tokens() calls 1 function(s): _resize.
What calls _count_image_tokens()?
_count_image_tokens() is called by 1 function(s): get_num_tokens_from_messages.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free