-
-
Notifications
You must be signed in to change notification settings - Fork 3k
[Fix]: Add cost tracking for image edits endpoint [OpenAI, Azure] #11186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds cost tracking support for the image edits endpoint on both OpenAI and Azure, including new call types, cost calculator logic, and corresponding async tests.
- Introduces
image_edit
andaimage_edit
toCallTypes
- Extends cost calculator to include image edit responses via
CostCalculatorUtils
- Adds async unit tests to verify cost logging with a custom logger for OpenAI and Azure
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
File | Description |
---|---|
tests/image_gen_tests/test_image_edits.py | Adds test_openai_image_edit_cost_tracking and test_azure_image_edit_cost_tracking along with a TestCustomLogger class |
litellm/types/utils.py | Adds new enum entries for image_edit and aimage_edit and updates ImageResponse to accept extra kwargs |
litellm/litellm_core_utils/llm_cost_calc/utils.py | Implements _call_type_has_image_response to include image edit types |
litellm/cost_calculator.py | Uses CostCalculatorUtils for image response checks and refactors model name handling in default_image_cost_calculator |
Comments suppressed due to low confidence (2)
tests/image_gen_tests/test_image_edits.py:9
- The test references
patch
,AsyncMock
,json
, andTEST_IMAGES
but none of these are imported or defined. Addimport json
andfrom unittest.mock import patch, AsyncMock
, and ensureTEST_IMAGES
is imported or defined.
import base64
litellm/cost_calculator.py:1140
- The type hints List and Optional are used here but not imported in this module, which will cause a NameError. Please add
from typing import List, Optional
at the top of the file.
models_to_check: List[Optional[str]] = [
…rriAI#11186) * fix: add cost tracking for image edits * fix: add cost tracking for azure image edits * fix: fix linting error * fix: fixes for background param * fix: image edit test fixes * fix: openai image edit cost tracking
[Fix]: Add cost tracking for image edits endpoint [OpenAI, Azure]
Relevant issues
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/litellm/
directory, Adding at least 1 test is a hard requirement - see detailsmake test-unit
Type
🐛 Bug Fix
✅ Test
Changes