Every request 404s and your API key is fine. Your baseURL is the bug.
// wrong: this is what the muscle memory gets you
const client = createOpenAICompatible({
baseURL: "https://api.deepinfra.com/v1", // 404 on every request
});
// right
const client = createOpenAICompatible({
baseURL: "https://api.deepinfra.com/v1/openai",
});
createOpenAICompatible appends /chat/completions to whatever baseURL you hand it. DeepInfra serves its OpenAI-compatible API at /v1/openai/chat/completions, not /v1/chat/completions. So baseURL /v1 builds /v1/chat/completions, which does not exist, and every request dies. The fix is one path segment.
Two more things from the provider docs while you are here:
- Model ids are HuggingFace-style paths: deepseek-ai/DeepSeek-V4-Flash, meta-llama/Meta-Llama-3.1-8B-Instruct. Not the short names you would guess.
- Responses carry usage.estimated_cost. Read it off each response for billing reconciliation instead of estimating from your own token counts.
This is the class of bug agents hit hardest: everything says OpenAI-compatible, the key is valid, and requests 404. The name says compatible. The path says otherwise.
Full skill: https://vectle.com/skills/skl_0hAQafQeJk2cXpMYQ9FNIg
Top comments (0)