Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Inconsistent base_url behavior with module client and OpenAIClient

Aperta
#1,373 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@SmartManoj ci sta già lavorando.

Dal 2/3/2025.

  • #2157 di @SmartManoj — aperta
  • #2990 di @LittleChenLiya — chiusa senza merge

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
api

Direzione di ricerca

Inizia tracciando come viene gestito base_url per module client e OpenAI client, usando i due snippet di riproduzione come confronto comportamentale. Fai in modo che entrambi i client costruiscano la stessa completion URL valida quando la base URL non contiene una barra finale, quindi verifica che i due percorsi di chiamata producano richieste coerenti.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug sdk
Confirm this is an issue with the Python library and not an underlying OpenAI API
  • This is an issue with the Python library
Describe the bug

The issue is that the base_url in the OpenAI client enforces a trailing slash whereas setting the module openai.base_url does not enforce.

This is 100% reproducible and while it can be worked around, the inconsistency in clients causes issues in scripts that use both clients.

To Reproduce
  1. Create a module client and use a base_url without a trailing slash. See error with URL for completions
  2. Create an OpenAIClient and use a base_url without a trailing slash. See no erros.
Code snippets

This works

    client = openai.OpenAI(
        api_key=my_key,
        base_url="https://myllmserver.com/api/v1"
    )
    print(client.completions.create(
       model="mistralai/Mistral-7B-Instruct-v0.2",
       prompt="test" 
    ))

This does not:

    openai.base_url="https://myllmserver.com/api/v1"
    openai.api_key=my_key
    print(openai.completions.create(
       model="mistralai/Mistral-7B-Instruct-v0.2",
       prompt="test"
    ))

Error:

https://myllmserver.com/api/v1completions "HTTP/1.1 404 Not Found"
OS

macOS

Python version

Python v3.12

Library version

openai v1.23.6

Lingua principale
Python
Stelle
31.8k
Fork
7.3k
Merge medio
1g 3h
PR unite (30g)
131

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di openai/openai-python

Tutte le issue di openai/openai-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.