# AI Inference API

`Azion.AI.run` is the binding a [function](/en/documentation/platform/functions/) calls to invoke a model on [AI Inference](/en/documentation/platform/ai-inference/). It is a global of [Azion Runtime](/en/documentation/devtools/runtime/), so a function reaches it with no import line and no credential. The binding carries the model id and the request body. The fields that body accepts, and the object the model returns, are the same over the HTTP endpoint and are documented in [Model invocation](/en/documentation/platform/ai-inference/model-invocation/).

> **Note**
>
> Under `azion dev`, `Azion.AI` is `undefined`, and a call to `Azion.AI.run` throws `TypeError: Cannot read properties of undefined (reading 'run')`. Test model calls on a deployed function.

---

## Parameters

`Azion.AI.run` takes two parameters, and the call is asynchronous: a function awaits it and reads the model response from the resolved value.

| Parameter    | Type   | Description                                                                   |
| ------------ | ------ | ----------------------------------------------------------------------------- |
| Model id     | string | The id of the model to invoke, in the form its model page states.             |
| Request body | object | The request fields for the operation. The model id is not repeated inside it. |

Model ids differ in form between models, so copy the id from the model's own page in [AI models](/en/documentation/platform/ai-inference/models/) rather than deriving it from the model name.

---

## Call a model

A call to a chat model inside a function:

```ts
const modelResponse = await Azion.AI.run("Qwen/Qwen3-30B-A3B-Instruct-2507-FP8", {
  "stream": false,
  "messages": [
    { "role": "system", "content": "You are a helpful assistant." },
    { "role": "user", "content": "Name three European capitals." }
  ]
})
return modelResponse
```

---

## Return value

The resolved value is the object the model returns: a `chat.completion` object from a chat model, a `list` of embeddings from an embedding model, and the ranked results from a reranking model. The generated text of a chat model sits at `modelResponse?.choices?.[0]?.message?.content`, which is the content of the first entry in `choices`. Every field of the three shapes is listed in [Model invocation](/en/documentation/platform/ai-inference/model-invocation/#response-fields).

---

## Related resources

- [Model invocation](/en/documentation/platform/ai-inference/model-invocation.md): The request fields the body accepts, the HTTP endpoint, and the object each model returns.
- [AI models](/en/documentation/platform/ai-inference/models.md): The id to pass, and the capabilities each model states for itself.
- [AI Inference](/en/documentation/platform/ai-inference.md): What the product runs and when to use it.
- [Functions](/en/documentation/platform/functions.md): The runtime that holds the binding and the limits that bound a call.
