Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(ollama): forward API key to backend - #4533

Open
mameikagou wants to merge 2 commits into
TabbyML:mainfrom
mameikagou:codex/fix-ollama-api-key-auth
Open

fix(ollama): forward API key to backend#4533
mameikagou wants to merge 2 commits into
TabbyML:mainfrom
mameikagou:codex/fix-ollama-api-key-auth

Conversation

@mameikagou

Copy link
Copy Markdown

Forward configured Ollama API keys as sensitive Authorization: Bearer headers. This updates the pinned ollama-rs revision for header support and adapts the embedding call to its current API.

Validation: cargo test -p ollama-api-bindings --locked --lib

Fixes #4525

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 addresses Ollama backends that require bearer-token authentication by forwarding configured API keys as Authorization: Bearer ... headers, while also updating the ollama-rs dependency and adapting the embedding call to the current ollama-rs embeddings API.

Changes:

  • Add header injection for ollama/completion requests via ollama-rs header support.
  • Update the embedding request path to use GenerateEmbeddingsRequest and handle the response shape by selecting the first embedding.
  • Bump the pinned ollama-rs git revision and add tokio dev-dependencies to support new unit tests.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
crates/ollama-api-bindings/src/embedding.rs Switch embedding call to the new ollama-rs embeddings request API and add a unit test for response handling.
crates/ollama-api-bindings/src/completion.rs Add connection setup that forwards API keys as Authorization headers and add a unit test verifying the header is sent.
crates/ollama-api-bindings/Cargo.toml Update ollama-rs revision/features (adds headers) and add tokio dev-dependencies for tests.
Cargo.lock Lockfile updates from the ollama-rs revision bump and transitive dependency changes.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/ollama-api-bindings/src/embedding.rs
Comment thread crates/ollama-api-bindings/src/completion.rs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Server panics with "Invalid or missing API key" and crash-loops when using ollama/completion with api_key configured

2 participants