An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
404 Response when executing GetInputTokenCountAsync with azure endpoint
Describe the bug
When OpenAIClient is configured with an Azure OpenAI v1 compatibility endpoint (https://xxx.openai.azure.com/openai/v1/), calling GetInputTokenCountAsync throws ClientResultException: HTTP 404 — Unknown request URL: POST /v1/responses/input_tokens. This azure openai endpoint is from the code sample when viewing deployment details on azure foundry.
Steps to reproduce
Steps to reproduce
- Construct OpenAIClient with OpenAIClientOptions { Endpoint = new Uri("https://.openai.azure.com") } and an API key.
- Get the response client: var responsesClient = openClient.GetResponsesClient();
- Build a request body as BinaryContent.
- Call await client.GetInputTokenCountAsync(contentType, content);
Code snippets
OpenAIClient openClient = new(
credential: new ApiKeyCredential(apiKey),
options: new OpenAIClientOptions()
{
Endpoint = new(endpoint),
});
var responsesClient = openClient.GetResponsesClient();
CreateResponseOptions chatOptions = new()
{
Model = deploymentName,
Instructions = "You are a helpful assistant that talks like a pirate."
};
chatOptions.InputItems.Add(ResponseItem.CreateUserMessageItem("Hi, can you help me?"));
chatOptions.InputItems.Add(ResponseItem.CreateAssistantMessageItem("Arrr! Of course, me hearty! What can I do for ye?"));
chatOptions.InputItems.Add(ResponseItem.CreateUserMessageItem("What's the best way to train a parrot?"));
var countRequestBody = JsonSerializer.Serialize(chatOptions);
var response = await responsesClient.GetInputTokenCountAsync(
"application/json",
BinaryContent.Create(BinaryData.FromString(countRequestBody)));
Windows
.NET version
10
Library version
2.10.0
Azure OpenAI in Foundry Models
1 answer
Sort by: Most helpful
-
AI answer
2026-05-13T16:48:58.5666667+00:00 GetInputTokenCountAsyncis calling the Responses API endpoint/v1/responses/input_tokens. A 404 from an Azure OpenAI v1‑compatibility endpoint means that this specific path is not implemented on that endpoint.In Azure AI Foundry / Azure OpenAI today:
- A 404 for Responses API calls generally indicates that the
model/deployment or the path does not match what the resource supports. - The v1‑compatibility endpoint (
...openai.azure.com/openai/v1/) does not expose every preview feature or helper route; only the documented REST paths are guaranteed to exist.
So, when
OpenAIClientis pointed athttps://<resource>.openai.azure.com/openai/v1/, the SDK’sGetInputTokenCountAsynctries to POST to/v1/responses/input_tokens, but the Azure endpoint does not recognize that URL and returns 404Unknown request URL.To resolve this in the current platform behavior:
- Do not rely on
GetInputTokenCountAsyncagainst the Azure v1‑compatibility endpoint, because the/v1/responses/input_tokensroute is not available there. - Use only the supported Azure OpenAI REST/SDK operations for your resource and region, as documented for the Responses API. If token counting is required, implement it client‑side (for example, by using a tokenizer compatible with the target model) instead of calling
/v1/responses/input_tokens. - When troubleshooting 404s with Azure OpenAI endpoints, always verify:
- The endpoint path matches the documented Azure OpenAI pattern (
...openai.azure.com/openai/v1/). - The
modelvalue in the request matches an existing deployment name for that resource.
- The endpoint path matches the documented Azure OpenAI pattern (
If the same client and key work for other Responses API calls (for example,
create-response) but onlyGetInputTokenCountAsyncfails with 404, that confirms the issue is the unsupportedinput_tokensroute rather than authentication or deployment configuration.
References:
- Use the Azure OpenAI Responses API
- Azure OpenAI supported programming languages (programming-language-javascript)
- Azure OpenAI supported programming languages (programming-language-python)
- Azure OpenAI: OpenAI Assistants client library for .NET - version 1.0.0-beta.4
- Azure AI Projects OpenAI client library for .NET - version 2.0.0-beta.1
- Azure AI Extensions OpenAI client library for .NET - version 2.0.0
- Azure OpenAI in Microsoft Foundry Models REST API v1 preview reference
- Are Anthropic models deployed via Azure AI Foundry officially supported with third-party tools such as HAI or Cline? - Microsoft Q&A
- Azure Deployment Takes 70 Minutes to Fail with Obscure Error - Microsoft Q&A
- Static web app display azure 404 error - Microsoft Q&A
- Synapse Worspace Connectivity Error. - Microsoft Q&A
- Microsoft Foundry publish to Teams Bot service error - Microsoft Q&A
AI-generated content may be incorrect. Read our transparency notes for more information. - A 404 for Responses API calls generally indicates that the