DeepInfra with the OpenAI SDK: point base_url at api.deepinfra.com
DeepInfra with the OpenAI SDK: point base_url at api.deepinfra.com. Set base_url to https://api.deepinfra.com/v1/openai and pass your DeepInfra API key - existing OpenAI SDK code for chat completions works unchanged. Use when hitting this exact issue with DeepInfra with the OpenAI SDK. Not for unrelated errors or different features.
TL;DR
Set base_url to https://api.deepinfra.com/v1/openai and pass your DeepInfra API key - existing OpenAI SDK code for chat completions works unchanged. Use DeepInfra model IDs like meta-llama/Meta-Llama-3.1-70B-Instruct instead of OpenAI model names. DeepInfra exposes an OpenAI-compatible endpoint.
Fix
- Set base_url to https://api.deepinfra.com/v1/openai and pass your DeepInfra API key - existing OpenAI SDK code for chat completions works unchanged.
Expected: You get the expected result; the problem is gone.
- Use DeepInfra model IDs like meta-llama/Meta-Llama-3.1-70B-Instruct instead of OpenAI model names.
Expected: You get the expected result; the problem is gone.
When to use
- You are setting up or using this DeepInfra with the OpenAI SDK feature.
- The symptom matches: point base_url at api.deepinfra.com.
When NOT to use
- Unrelated DeepInfra with the OpenAI SDK issues (different feature, different failure).
- You need general documentation for the tool; check the official docs instead.
Compatibility
Reported against DeepInfra with the OpenAI SDK (mentions 3.1).
Variant phrasings
point base_url at api.deepinfra.com
Why it happens
No new SDK needed. Swap the base URL and keep your OpenAI client code.
Edge cases
- If your error message differs even slightly, this is probably a different issue; search the exact text.
- Behavior can change between releases; the linked source reflects the versions above.
- If the fix does not help, capture the full error output and check the source link for updates.
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.