I followed the Microsoft documentation to set up my Azure OpenAI resource and deployed a model successfully. The deployment shows as completed and I can use it fine in the Azure OpenAI Studio playground.
However, when I try to call the REST API endpoint, I keep getting a 404 Resource Not Found error. I’m using the exact URL and JSON payload that I copied from the Code View section in the playground.
My API call looks like this:
POST https://myapp-openai.openai.azure.com/openai/deployments/text-model/completions?api-version=2022-12-01
Headers:
api-key: [my-api-key]
Body:
{
"prompt": "Hello world",
"max_tokens": 50
}
The model works perfectly in the web interface but fails via API. What could be causing this 404 error? Is there some configuration step I might have missed?
Had this exact problem last month - drove me crazy for hours. Your deployment region probably isn’t matching your base URL. Double-check if your resource actually deployed where you think it did. Azure loves putting stuff in random regions sometimes. Also make sure your subscription has API permissions, not just portal access. The playground uses totally different auth than direct API calls. Try a simple GET request to your base endpoint first (skip the deployment path) and see what happens. If that bombs, your resource URL’s definitely wrong. When it works in Studio but not via API, it’s usually auth or URL formatting screwing you over.
double check your api version, i had a similar issue. try updating it to 2023-05-15. also, ensure ur deployment name in the url is exactly as it is in azure, cause its case senstive. little typos can ruin everythng!
Sounds like an endpoint URL issue. You’re using the completions endpoint, but if you deployed GPT-3.5 or GPT-4, you need the chat/completions endpoint instead. Super common mixup - the playground works with both, but the API’s picky about which one you use. Double-check your resource name too. I’ve wasted hours debugging this stuff only to find I had one character wrong in the URL. Just grab the exact endpoint from your Azure portal (Keys and Endpoint section) instead of building it yourself.
check your content-type header - it needs to be application/json. got a 404 when i missed that. azure can be super cryptic with errors. also, verify your api key permissions; they sometimes get made without proper access.