[PR #8321] [CLOSED] feat(openai): add optional authentication for OpenAI compatible API #12687

Closed
opened 2026-04-13 00:07:01 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/8321
Author: @myaniu
Created: 1/6/2025
Status: Closed

Base: mainHead: main


📝 Commits (1)

  • 958d01b feat(openai): add optional authentication for OpenAI compatible API

📊 Changes

2 files changed (+51 additions, -5 deletions)

View changed files

📝 openai/openai.go (+46 -0)
📝 server/routes.go (+5 -5)

📄 Description

Add authentication middleware that checks API key when OPENAI_API_KEY environment variable is set. When OPENAI_API_KEY is not set, maintain current behavior of allowing all requests. When set, clients must provide matching Bearer token in Authorization header.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/8321 **Author:** [@myaniu](https://github.com/myaniu) **Created:** 1/6/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (1) - [`958d01b`](https://github.com/ollama/ollama/commit/958d01b50cd4c5d2ccee7280d090db383083be30) feat(openai): add optional authentication for OpenAI compatible API ### 📊 Changes **2 files changed** (+51 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `openai/openai.go` (+46 -0) 📝 `server/routes.go` (+5 -5) </details> ### 📄 Description Add authentication middleware that checks API key when OPENAI_API_KEY environment variable is set. When OPENAI_API_KEY is not set, maintain current behavior of allowing all requests. When set, clients must provide matching Bearer token in Authorization header. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-13 00:07:01 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#12687