Skip to content

Commit d7f8af5

Browse files
Izayoi9claudeSoulter
authored
feat: auto-append /v1 to embedding_api_base in OpenAI embedding provider (#6863)
* fix: auto-append /v1 to embedding_api_base in OpenAI embedding provider (#6855) When users configure `embedding_api_base` without the `/v1` suffix, the OpenAI SDK does not auto-complete it, causing request path errors. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: ensure API base URL for OpenAI embedding ends with /v1 or /v4 --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Soulter <905617992@qq.com>
1 parent adc252a commit d7f8af5

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

astrbot/core/provider/sources/openai_embedding_source.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,15 @@ def __init__(self, provider_config: dict, provider_settings: dict) -> None:
2424
if proxy:
2525
logger.info(f"[OpenAI Embedding] {provider_id} Using proxy: {proxy}")
2626
http_client = httpx.AsyncClient(proxy=proxy)
27-
api_base = provider_config.get(
28-
"embedding_api_base", "https://api.openai.com/v1"
29-
).strip()
27+
api_base = (
28+
provider_config.get("embedding_api_base", "https://api.openai.com/v1")
29+
.strip()
30+
.rstrip("/")
31+
.rstrip("/embeddings")
32+
)
33+
if api_base and not api_base.endswith("/v1") and not api_base.endswith("/v4"):
34+
# /v4 see #5699
35+
api_base = api_base + "/v1"
3036
logger.info(f"[OpenAI Embedding] {provider_id} Using API Base: {api_base}")
3137
self.client = AsyncOpenAI(
3238
api_key=provider_config.get("embedding_api_key"),

0 commit comments

Comments
 (0)