# Open Neural Network Exchange (ONNX)

> An open file type for AI models. A model made in one tool runs in others.

**Field:** Artificial Intelligence  
**Category:** MLOps & Deployment  
**Also known as:** ONNX, ONNX Format, .onnx File

## Think of it like

It is like saving a story as a PDF. It opens the same way on almost any device.

## Definition

ONNX is an open file format for machine learning models. You train a model in one tool, such as PyTorch, and save it as a single .onnx file. Many other tools and chips can then run that file, from servers to phones and web pages. This frees the model from the tool it was made in. It is a graduated project of the LF AI & Data Foundation.

## Example

Emma trains a photo model in PyTorch and saves it as ONNX. She runs that same file in her web app and her phone app.

## Example code

```python
torch.onnx.export(model, sample_input, "model.onnx")
```

One line turns a PyTorch model into one .onnx file. Other tools can then run it.

## Why it matters

The tool that trains best is often not the one that runs best. ONNX lets you pick each one apart.

## Common mistake

Thinking every model carries over cleanly. Some parts may not, so check the new file gives the same answers.

## Three principles

- **One file.** The whole model in a single .onnx file.
- **Runs anywhere.** Servers, phones, browsers and many chips.
- **Open standard.** Not owned by one company.

## Related terms

- [Model Serving](https://learn.benibix.com/term/ai/model-serving)
- [PyTorch](https://learn.benibix.com/term/ai/pytorch)
- [Safetensors](https://learn.benibix.com/term/ai/safetensors)
- [Edge AI](https://learn.benibix.com/term/ai/edge-ai)
- [Model Weights File](https://learn.benibix.com/term/ai/model-weights)

![Four panels. A model trained in PyTorch is saved as one ONNX file and runs on a phone, a browser and a server. A big slow model becomes a small fast one. Live requests go to the old model and a copy goes to a new model whose answers are only logged. Training data and live data, side by side, with one input that does not match.](https://learn.benibix.com/diagrams/ai7-serving-path.svg)

---

Source: https://learn.benibix.com/term/ai/onnx
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
