# Troubleshoot AI Inference

This page covers the symptoms of a model call to [AI Inference](/en/documentation/platform/ai-inference/), made by a Function with `Azion.AI.run` or sent to the endpoint of the AI Inference Starter Kit. A quoted error from the binding is the `message` of the error that `Azion.AI.run` throws. A quoted error from the endpoint is the `error` field of its JSON response.

---

## A model call fails with model not found or not allowed

`Azion.AI.run` throws this error, and the model does not run:

```text
AIError: model not found or not allowed
```

The model id does not exist, or the account has no access to AI Inference. The message does not say which. A `model` value copied from an earlier response can also fail, because a response carries the account's internal id, which the binding can refuse as input.

- **Copy the id from the model page**: each page in [AI models](/en/documentation/platform/ai-inference/models/#model-ids) states an id that answers.
- **List the ids the account can call**: `Azion.AI.models()` returns them, as [List models](/en/documentation/devtools/runtime/api-reference/ai/#list-models) shows.
- **Check the access of the plan**: on the Hobby and Pro plans, AI Inference is available upon request, per [Access by plan](/en/documentation/platform/ai-inference/limits/#access-by-plan).

With an id from that list, the call returns the model response.

---

## A model call fails with a validation error

`Azion.AI.run` throws an error that names a type and a field, and the model does not run:

```text
AIError: validation error: Required {
    path: "/query",
}
```

The request body does not match the schema of the model. `Required` marks a missing field, `WrongType` a value of the wrong type, `Minimum` or `Maximum` a value past a bound, `Enum` a value outside a fixed set, and `OneOf` a message that matches no message object.

- **Fix the field that path names**: [Request fields](/en/documentation/platform/ai-inference/model-invocation/#request-fields) lists each field with its type and bounds.
- **Use query and documents on the reranker**: the BAAI reranker refuses the `text_1` and `text_2` pair with `Required`, per [Reranking requests](/en/documentation/platform/ai-inference/model-invocation/#reranking-requests).
- **Pick a listed width for dimensions**: Qwen3 Embedding 4B refuses a value outside its list with `Enum`, per [Embedding requests](/en/documentation/platform/ai-inference/model-invocation/#embedding-requests).

Once the body matches the schema, the call returns the model response.

---

## A model call fails with Request failed with status 400

`Azion.AI.run` throws an error that carries a status and no reason:

```text
Error: Request failed with status 400
```

The model server refused a request that passed validation. The causes observed are a `tools` request without `tool_choice` on Qwen2.5 VL AWQ 3B, Qwen2.5 VL AWQ 7B, or Nanonets-OCR-s, a prompt longer than the context the model serves, `stream_options` without `stream`, an unknown `tool_choice`, a `seed` that is not an integer, and `temperature` and `top_p` at `0` with both penalties at `-2`.

- **Name the tool on the Qwen2.5 VL models**: a tool named in `tool_choice` returns `tool_calls`, as [Tool calling](/en/documentation/platform/ai-inference/qwen-2-5-vl-3b/#tool-calling) shows. Nanonets-OCR-s takes no tools.
- **Shorten the prompt**: [AI models](/en/documentation/platform/ai-inference/models/) states the context length of each model.
- **Check the values against the list**: [Errors](/en/documentation/platform/ai-inference/model-invocation/#errors) lists every request the model server refuses.

After the change, the call returns the model response.

---

## An image request fails with Request failed with status 500

A request with an `image_url` part throws this error:

```text
Error: Request failed with status 500
```

The URL in `image_url.url` does not serve an image, so the model has nothing to read.

- **Use a URL that serves an image**: an `https` URL that returns the image, or a `data:` URL that carries the image in base64, per [Message objects](/en/documentation/platform/ai-inference/model-invocation/#message-objects).

With a URL that serves an image, the model answers in text.

---

## GPT-OSS 20B returns no content

A response from GPT-OSS 20B carries `content` set to `null` and `finish_reason` set to `length`.

The model reasons before it answers, and the reasoning counts against `max_tokens`. With a small `max_tokens`, the reasoning uses the whole budget, and no answer text remains. The reasoning itself is in `reasoning_content`.

- **Raise max_tokens**: leave room for the reasoning and the answer, as [Chat completion](/en/documentation/platform/ai-inference/gpt-oss-20b/#chat-completion) shows.

With room for both, `content` carries the answer and `finish_reason` is `stop`.

---

## An embedding has 2560 values instead of 4096

A request to Qwen3 Embedding 4B with `dimensions` set to `4096` returns a vector of 2560 values, which does not match a vector column declared for 4096 values.

The model accepts `4096`, but its largest vector has 2560 values. A request without `dimensions` also returns 2560 values.

- **Ask for a width the model returns**: `256`, `512`, `1024`, or `2048` return that width, per [Embedding](/en/documentation/platform/ai-inference/qwen3-embedding-4b/#embedding).
- **Size the column for 2560 values**: when the request asks for `4096` or for no width, declare the vector column with 2560 values.

The vector and the column then have the same width.

---

## A request field has no effect

A field in the request body changes nothing in the response, and no error is returned.

The binding accepts a field that the model does not know and ignores it, so a misspelled field name passes silently. A `model` field in the body is ignored as well: the first argument of `Azion.AI.run` decides the model.

- **Spell the field as the reference lists it**: [Request fields](/en/documentation/platform/ai-inference/model-invocation/#request-fields) gives each name.
- **Pass the model id as the first argument**: change the first argument of `Azion.AI.run` to call another model.

With the field spelled as listed, the response reflects it.

---

## Azion.AI is undefined when the Function runs locally

Under `azion dev`, a call to `Azion.AI.run` throws this error:

```text
TypeError: Cannot read properties of undefined (reading 'run')
```

`Azion.AI` exists only in a deployed Function. Under `azion dev`, it is `undefined`, per the [AI Inference API](/en/documentation/devtools/runtime/api-reference/ai/).

- **Test model calls on a deployed Function**: deploy the Function, then send the request to its domain.

On a deployed Function, the call returns the model response.

---

## The endpoint answers Request must be a POST request with JSON body

The endpoint of the AI Inference Starter Kit answers `400` with this body:

```json
{"error":"Request must be a POST request with JSON body"}
```

The Function the template installs accepts only a `POST` request whose `Content-Type` header is exactly `application/json`. A browser that opens the domain sends a `GET`, and a client that adds `; charset=utf-8` to the header is refused too.

- **Send a POST request**: the [quickstart](/en/documentation/platform/ai-inference/quickstart/#send-a-request-to-the-model) shows one with `curl`.
- **Send the header with no parameter**: set `Content-Type` to `application/json`.

The endpoint then returns the model response.

---

## The endpoint answers Missing model field or Invalid JSON

The endpoint of the AI Inference Starter Kit answers `400` with one of two bodies. For a body without the `model` field:

```json
{
  "error": "Missing 'model' field in request body"
}
```

For a body that does not parse as JSON:

```json
{
  "error": "Invalid JSON in request body"
}
```

The Function the template installs reads the model id from the `model` field of the body. A body without `model`, or a body that does not parse as JSON, stops before the model call.

- **Add the model field**: set `model` to an id from [AI models](/en/documentation/platform/ai-inference/models/).
- **Send valid JSON**: check the quoting of the body your client sends.

The endpoint then returns the model response.

---

## The endpoint answers AI internal error

The endpoint of the AI Inference Starter Kit answers `500` with this body:

```json
{"error":"AI internal error"}
```

The binding threw an error other than `model not found or not allowed` or a validation error, such as a refusal from the model server. The body does not carry that error, but the Function the template installs writes it to the console.

- **Read the console line of the request**: the [Functions Console](/en/documentation/platform/real-time-events/data-sources/#functions-console) data source of Real-Time Events carries the lines a Function writes, including the error name and message.
- **Match the message to its cause**: the entries above cover each message observed.

The console line names the refusal, and the fix for that message applies.

---

## The endpoint answers 404 right after the deployment

Right after you deploy the AI Inference Starter Kit, the domain under **Visit site** answers `404` with Azion's placeholder page.

The deployment has not propagated to Azion's data centers yet. Propagation takes several minutes.

- **Repeat the request after several minutes**: as [Open the workload domain](/en/documentation/platform/ai-inference/quickstart/#open-the-workload-domain) describes.

Once the deployment propagates, the domain answers with the Function's response.

---

## Application Name is refused when you deploy the template

When you deploy the AI Inference Starter Kit, the **Application Name** field shows this message:

```text
The use of accents and/or special characters is not allowed.
```

The field accepts letters, numbers, and underscores only, so a hyphen is refused.

- **Use underscores**: enter a name such as `ai_inference_starter_kit`, the default.

The **Deploy** button then deploys the template.

---

## Related resources

- [Model invocation](/en/documentation/platform/ai-inference/model-invocation.md): Every request field, the response fields, and the errors of the binding and of the endpoint.
- [AI models](/en/documentation/platform/ai-inference/models.md): The id, context length, and capabilities of each model.
- [AI Inference limits](/en/documentation/platform/ai-inference/limits.md): Access by plan, and when Azion terminates or deprovisions a model.
- [Get started with AI Inference](/en/documentation/platform/ai-inference/quickstart.md): Deploy the template and send a first request to a model.
