Skip to content

[Bug]: When calling remote Ollama model, LiteLLM tries to access localhost for cost calculation #10952

@FlorianVal

Description

@FlorianVal

What happened?

When Calling a remote Ollama server, LiteLLM makes a call to localhost in order to compute cost. I don't expect LiteLLM to call localhost if I'm running with non-localhost ollama server.

Related to #9602. When passing api_base to completion() it is not fully taken into account, Thus calling localhost.

Relevant log output

INFO:httpx:HTTP Request: POST http://my_remote_server:11434/api/generate "HTTP/1.1 200 OK"
19:42:06 - LiteLLM:INFO: utils.py:1211 - Wrapper: Completed Call, calling success_handler
INFO:LiteLLM:Wrapper: Completed Call, calling success_handler
19:42:06 - LiteLLM:INFO: cost_calculator.py:655 - selected model name for cost calculation: ollama/qwen3:0.6b
INFO:LiteLLM:selected model name for cost calculation: ollama/qwen3:0.6b
INFO:httpx:HTTP Request: POST http://localhost:11434/api/show "HTTP/1.1 404 Not Found"
19:42:06 - LiteLLM:INFO: cost_calculator.py:655 - selected model name for cost calculation: qwen3:0.6b
INFO:LiteLLM:selected model name for cost calculation: qwen3:0.6b
INFO:httpx:HTTP Request: POST http://localhost:11434/api/show "HTTP/1.1 404 Not Found"
INFO:httpx:HTTP Request: POST http://localhost:11434/api/show "HTTP/1.1 404 Not Found"
19:42:06 - LiteLLM:INFO: cost_calculator.py:655 - selected model name for cost calculation: ollama/qwen3:0.6b
INFO:LiteLLM:selected model name for cost calculation: ollama/qwen3:0.6b
INFO:httpx:HTTP Request: POST http://localhost:11434/api/show "HTTP/1.1 404 Not Found"
19:42:06 - LiteLLM:INFO: cost_calculator.py:655 - selected model name for cost calculation: qwen3:0.6b
INFO:LiteLLM:selected model name for cost calculation: qwen3:0.6b
INFO:httpx:HTTP Request: POST http://localhost:11434/api/show "HTTP/1.1 404 Not Found"
INFO:httpx:HTTP Request: POST http://localhost:11434/api/show "HTTP/1.1 404 Not Found"

Are you a ML Ops Team?

No

What LiteLLM version are you on ?

V1.70.0

Twitter / LinkedIn details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions