AI Inference
Run a language, vision, embedding, or reranking model from a Function with Azion.AI.run, with no inference infrastructure to provision.
AI Inference is a Platform Resource that runs open-source AI models on Azion’s distributed infrastructure, in response to the calls your Functions send. Running a trained model on an input is called inference: the model computes an output from the weights it learned in training. That output can be generated text, a ranking, or a vector of numbers that represents the input. A model answers only after its weights sit in memory, on hardware sized for them. An inference service keeps the models in memory, so you provision no hardware for them.
A Function passes a model id and a request body to Azion.AI.run, then awaits the model response. Use AI Inference to generate text from a prompt, extract the text from an image, convert a document into a vector for retrieval, or rank a set of documents against a query.
Request path
A Function calls a model while it handles a request, so the request stays open until the model response returns. The diagram follows one request from the client to the model and back.
Solid arrows carry the request, and dotted arrows carry the response. Each label starts with the number of its step below.
- The request reaches a data center near the client through a domain of your Workload. The deployment of that Workload sets the Application that receives it.
- A rule of the Application runs the Function with the Run Function behavior.
- The Function passes the model id and the request body to
Azion.AI.run. - AI Inference runs the model and returns its response to the Function.
- The Function builds its response from the model response, and the Application delivers it to the client.
Workloads receives the request, Applications runs the rule, and Functions runs your code on Azion Runtime. To see which side of that path Azion operates and which side you own, refer to How AI Inference works.
Function code
This Function code sends a chat request to a model and reads the generated text:
Azion.AI.runtakes the model id first: the string a model answers to. Ids follow no single pattern, so copy each one from the model’s page in AI models.- The request body comes second.
messagesholds the conversation, and fields such asstream,max_tokens, andtemperaturecontrol the output. Model invocation lists every field a body accepts. Azion.AI.runreturns a promise. The Function awaits it and finds the generated text atchoices[0].message.contentof the resolved value.- The code passes no host, no base URL, and no credential: the model id is the only address.
A request body or a response object written for the OpenAI chat completions format reads the same here, and only the call that sends it changes.
Scope and limits
- Access: on the Hobby and Pro plans, AI Inference is available upon request, subject to approval. For the access each plan gives, refer to AI Inference limits.
- Models: the catalog holds open-source large language models, vision language models that read text and images, an embedding model, and a reranker. Each model page states the id to pass and the capabilities the model supports, and
Azion.AI.models()returns the ids your account can call. For the full list, refer to AI models. - Context length: the context a model accepts varies by model, from 8k to 131k tokens across the catalog. Check the page of the model you call before you size a prompt.
- Input: all models accept text. A model that also accepts images reads each image from a URL, inside a content part of the message.
- Streaming: with
streamset totrue, the model streams its response instead of returning it whole. The endpoint of the AI Inference Starter Kit relays that stream as server-sent events, onedata:line per chunk, ending withdata: [DONE]. - Interfaces: a Function calls
Azion.AI.run, which takes no credential. Over HTTP, an Application deployed from the AI Inference Starter Kit template serves an OpenAI-compatible endpoint on its domain. Themodelfield of the request body selects the model, and the template configures no authentication in front of the endpoint. Both interfaces carry the request body that Model invocation documents. - Local testing: under
azion dev,Azion.AIisundefined, so test model calls on a deployed Function. For the error the local call throws, refer to AI Inference API. - Management: Azion Console has no AI Inference screen, and neither the v4 Azion API nor the Azion CLI has an operation for AI Inference or its models. The entity you create and manage is the Function that calls a model, through the interfaces Functions documents.
- Model adaptation: LoRA Fine-Tune, an extension of AI Inference, adapts a model to a task with Low-Rank Adaptation. Each model page states whether the model accepts it.
- Vectors: SQL Database stores and queries the vectors an embedding model returns. Vector search covers the semantic search a retrieval-augmented generation flow runs on them.
- Termination: Azion may terminate a model, without prior notice, when it consumes more than the maximum defined memory or runs longer than the maximum allowed time. A model created and not executed for more than three days may be deprovisioned. AI Inference limits covers each condition.
- Model terms: a model may carry third-party license terms, and you are responsible for complying with them and for the output the model generates. Azion does not verify that output for accuracy.
- Observability: because a model call runs inside a Function on an Application, its traffic shows where that Application’s traffic shows. Real-Time Metrics reports it, and Real-Time Events carries the requests and the Function’s console logs,
AIErrormessages included. - Billing: Pricing states how a model call is measured and charged.