Commit graph

34265 commits

Author SHA1 Message Date
Cesar Garcia
bdb02c092e
Merge pull request #18144 from Chesars/feat/bfl-image-generation 2026-03-04 23:38:16 -03:00
Chesars
d693007726 fix(bfl): check HTTP status when downloading image from URL
Add raise_for_status() to avoid sending error page content as image data to BFL API.
2026-03-04 23:36:44 -03:00
Chesars
fac6c068a0 fix(bfl): add mask to supported params for inpainting
mask was missing from get_supported_openai_params, causing it to be
dropped before reaching transform_image_edit_request where it is
already handled correctly for flux-pro-1.0-fill inpainting.
2026-03-04 23:17:15 -03:00
Chesars
fc54a65c2b fix(bfl): remove timeout from polling GET calls — HTTPHandler.get() doesn't accept timeout 2026-03-04 23:07:02 -03:00
Chesars
fa165a68d9 fix(bfl): add BFL-specific params to image edit get_supported_openai_params for consistency 2026-03-04 23:04:48 -03:00
Chesars
f3cb45765b fix(bfl): close docstring in get_supported_openai_params, prevent quality/n param leak for non-ultra models 2026-03-04 22:36:13 -03:00
Cesar Garcia
315a483ace
Update litellm/llms/black_forest_labs/image_generation/transformation.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-03-04 22:32:30 -03:00
Chesars
f2c75bdbe0 fix(bfl): add timeout to polling requests, validate initial POST status code
- Propagate timeout to each polling GET request to prevent indefinite hangs
- Validate HTTP status code of initial POST before parsing JSON
- Fix inline import and add 60s timeout to image URL download in _read_image_bytes
2026-03-04 22:20:59 -03:00
Cesar Garcia
6693723588
Merge pull request #22809 from Chesars/worktree-count-tokens-api
feat(openai): add litellm.acount_tokens() public API + OpenAI token counting support
2026-03-04 22:03:23 -03:00
Chesars
abc381cfe2 fix: use chat format in tools test, include tools/system in local fallback 2026-03-04 21:53:03 -03:00
Chesars
8786e674ee fix: address PR review feedback — F821, double auth, strict field, docs format, system-only fallback
- Fix F821: add BaseTokenCounter TYPE_CHECKING import in gpt_transformation.py
- Remove duplicate auth invocation in count_response_input_tokens endpoint
- Preserve `strict` field during chat→Responses API tool conversion
- Fix docs tools example to use chat completions format (not Responses API format)
- Return None early for system-only messages to avoid noisy error logs
2026-03-04 21:35:39 -03:00
Cesar Garcia
92b0585f2e
Update litellm/llms/openai/responses/count_tokens/handler.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-03-04 20:57:29 -03:00
Cesar Garcia
bbec0f7657
Update litellm/proxy/response_api_endpoints/endpoints.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-03-04 20:57:05 -03:00
Cesar Garcia
13dbcb182c
Update transformation.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-03-04 20:43:05 -03:00
Cesar Garcia
1fb38dfa31
Update litellm/llms/openai/responses/count_tokens/transformation.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-03-04 19:54:49 -03:00
Cesar Garcia
d346f5cfab
Merge pull request #17550 from Chesars/fix/gemini-async-streaming-custom-client-17148
Fix: User specified async client ignored with Gemini streaming+async
2026-03-04 19:46:51 -03:00
Cesar Garcia
59c64cb633
Update litellm/proxy/response_api_endpoints/endpoints.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-03-04 19:46:34 -03:00
Cesar Garcia
91928d9d67
Update litellm/llms/openai/responses/count_tokens/transformation.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-03-04 19:46:10 -03:00
Chesars
28a20c180f fix: add ProxyException handling to count_tokens endpoint
Match the error handling pattern used in the Anthropic count_tokens
endpoint: catch ProxyException separately to surface its status code
and message, and include error details in the generic 500 fallback.
2026-03-04 19:39:48 -03:00
Chesars
872554df42 Fix: User specified async client ignored with Gemini streaming+async
The user-specified async client was being overwritten by
`litellm.module_level_aclient` in `streaming_handler.py` when using
async+streaming with Gemini.

This fix adds a `gemini_client` parameter to `make_call()` (matching
the existing pattern in `make_sync_call()`) so the user's custom client
is preserved and not overwritten.

Fixes #17148
2026-03-04 19:38:08 -03:00
Chesars
c185652577 fix: avoid chat-format fallback for empty input_items, remove duplicate instructions and elif 2026-03-04 19:32:05 -03:00
Cesar Garcia
cb54215966 Update litellm/proxy/response_api_endpoints/endpoints.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-03-04 19:32:05 -03:00
Cesar Garcia
39762983b1 Update litellm/proxy/response_api_endpoints/endpoints.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-03-04 19:32:05 -03:00
Cesar Garcia
018750e0cd Update litellm/llms/openai/responses/count_tokens/transformation.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-03-04 19:32:05 -03:00
Chesars
d33dec86ad fix: address Greptile review feedback
- Log provider token counting failures instead of silently swallowing
- Fall back to local tokenizer when provider returns error response
- Map assistant tool_calls to Responses API function_call items
- Concatenate multiple system messages instead of overwriting
- Hide internal error details from proxy API responses
- Narrow exception catch in handler to network/JSON errors only
- Update test to match new fallback behavior
2026-03-04 19:32:05 -03:00
Chesars
43d2a19f79 feat(openai): add OpenAI token counting API support and public litellm.acount_tokens()
- Add OpenAITokenCounter using POST /v1/responses/input_tokens endpoint
- Add litellm.acount_tokens() public async API that auto-routes to provider APIs
- Add proxy endpoint POST /v1/responses/input_tokens for OpenAI-compatible counting
- Transform chat tools format to Responses API format for correct token counting
- Fall back to local tiktoken when provider API unavailable

Fixes #22302
2026-03-04 19:32:05 -03:00
Chesars
6fa9a0e52b fix(bfl): validate empty image list in edit handler
Raise explicit error instead of letting IndexError propagate when
an empty image list is passed to image_edit.
2026-03-04 19:23:37 -03:00
Cesar Garcia
835e4c4a75
Update litellm/llms/black_forest_labs/image_generation/transformation.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-03-04 19:20:19 -03:00
Cesar Garcia
d9f37011a2
Update litellm/llms/black_forest_labs/image_generation/transformation.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-03-04 19:20:03 -03:00
Cesar Garcia
92297df30c
Update docs/my-website/sidebars.js
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-03-04 19:19:30 -03:00
Chesars
88dc0c1b18 feat(bfl): add kontext models to image generation support
Kontext models (flux-kontext-pro, flux-kontext-max) support both
text-to-image and image editing. Add them to IMAGE_GENERATION_MODELS
and update supported_endpoints in model prices JSON.
2026-03-04 19:12:28 -03:00
Chesars
7ee4a40fc4 fix(bfl): correct mode and variable shadowing from review feedback
- Change mode from "image_generation" to "image_edit" for all 4 BFL
  image edit models (flux-kontext-pro, flux-kontext-max, flux-pro-1.0-fill,
  flux-pro-1.0-expand)
- Rename shadowed api_base variable to complete_url in async handler
  for consistency with sync path
2026-03-04 19:07:36 -03:00
Cesar Garcia
6fa74af6c3
Update litellm/llms/black_forest_labs/image_edit/transformation.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-03-04 19:06:45 -03:00
Cesar Garcia
269911d6fe
Update litellm/llms/black_forest_labs/image_edit/handler.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-03-04 19:06:22 -03:00
Chesars
cf01ef5949 fix(tests): align BFL test assertions with implementation
- image_edit: get_supported_openai_params returns [] not [n, size, response_format]
- image_generation: remove response_format assertion (not in supported params)
- image_generation: unknown model raises ValueError, not defaults to flux-pro-1.1
2026-03-04 18:47:59 -03:00
Chesars
52d2ea237f fix(bfl): remove unsupported params and error on unknown models
- Remove response_format from supported params (BFL always returns URLs)
- Remove n and size from image edit supported params (not mapped)
- Raise ValueError on unknown model names instead of silently defaulting
2026-03-04 18:34:05 -03:00
Cesar Garcia
8eb7ca3726
Update litellm/llms/black_forest_labs/image_edit/transformation.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-03-04 18:26:47 -03:00
Chesars
00cf9550af fix(bfl): handle URL and file path inputs in image edit
_read_image_bytes was not handling string inputs (URLs or file paths),
causing a TypeError when passing a URL as the image source.
2026-03-04 18:16:21 -03:00
Cesar Garcia
d9d39d545a
Update litellm/llms/black_forest_labs/image_edit/transformation.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-03-04 18:11:50 -03:00
Chesars
727fd76841 refactor(bfl): separate HTTP logic into dedicated handlers
- Create handler.py for image generation and image edit
- Move polling logic from transformation to handlers
- Handlers use _get_httpx_client() / get_async_httpx_client()
- Transformation files now only transform request/response data
- Follows Bedrock pattern for provider-specific handlers

Addresses feedback: transformation files should not make HTTP requests
2026-03-04 18:10:09 -03:00
Chesars
a14a79619a docs: add Black Forest Labs image generation documentation 2026-03-04 18:09:52 -03:00
Chesars
e0af575ee8 feat(black_forest_labs): add image generation support
Add native text-to-image generation for Black Forest Labs Flux models
(flux-pro-1.1, flux-pro-1.1-ultra, flux-dev, flux-pro).

- Polling-based async API with sync and async support
- OpenAI-compatible parameter mapping (size, n, quality)
- Reuses shared HTTP clients via _get_httpx_client()
- 39 unit tests added
2026-03-04 18:09:34 -03:00
Chesars
d180db31e7 Use _get_httpx_client for HTTP polling in BFL image edit
Replace direct httpx.get() calls with _get_httpx_client() to reuse
cached HTTP client, following the pattern used by other providers
(RunwayML, Azure AI OCR, Sagemaker, etc.).
2026-03-04 18:09:12 -03:00
Chesars
77ca224a7f docs: add Black Forest Labs image edit documentation 2026-03-04 18:09:12 -03:00
Chesars
23bda9cc8e fix: remove unused Union import 2026-03-04 18:08:50 -03:00
Chesars
f132f2c811 chore: add Black Forest Labs models to model registry
Add BFL models to model_prices_and_context_window.json with pricing:
- flux-kontext-pro: $0.04/image
- flux-kontext-max: $0.08/image
- flux-pro-1.0-fill: $0.05/image
- flux-pro-1.0-expand: $0.05/image

Add black_forest_labs_models set to __init__.py for model discovery.
2026-03-04 18:08:50 -03:00
Chesars
cd731811d9 feat(black_forest_labs): add native image edit support for Black Forest Labs
Add native integration for Black Forest Labs image editing models
(flux-kontext-pro, flux-kontext-max, flux-pro-1.0-fill, flux-pro-1.0-expand).

Changes:
- Add BlackForestLabsImageEditConfig for BFL API transformation
- Add BLACK_FOREST_LABS to LlmProviders enum
- Add use_multipart_form_data() to BaseImageEditConfig for JSON vs form-data
- Modify image_edit_handler to support JSON request bodies
- Add comprehensive unit tests

Closes #11401
2026-03-04 18:08:50 -03:00
Cesar Garcia
bc10274928
Merge pull request #19518 from Chesars/fix-model-management-ui
Fix model management page UI improvements
2026-03-04 18:02:55 -03:00
Cesar Garcia
2e9326523a
Update ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/ModelsAndEndpointsView.test.tsx
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-03-04 18:01:28 -03:00
Cesar Garcia
424c433141
Merge pull request #22801 from Chesars/feat/mistral-audio-transcription
feat(mistral): add Voxtral audio transcription support
2026-03-04 17:55:33 -03:00