# Code editor

The code editor is where you write the JavaScript of a [function](/en/documentation/platform/functions/) in Azion Console. It is built on the [Monaco Editor](https://microsoft.github.io/monaco-editor/docs.html), the editor used by [VS Code](https://code.visualstudio.com/). Each function carries its code in the **Code** tab, which opens with placeholder code that you replace. **Save** stores the code and makes the function available to instantiate on an application. Editing a function requires the **Edit Functions** permission on the account. For the path that reaches the editor from Azion Console, refer to [Quickstart](/en/documentation/platform/functions/quickstart/).

---

## Editor features

The code editor carries these Monaco Editor features:

- Syntax highlighting
- IntelliSense
- Debugging

The editor supports the [globals and types](/en/documentation/devtools/runtime/api-reference/azion-runtime-globals/) and the [Web APIs](/en/documentation/devtools/runtime/api-reference/javascript/) that [Azion Runtime](/en/documentation/devtools/runtime/) implements. The context menu of the editor also carries the **Format Document** command.

---

## Code preview

The code editor shows the response of the function while you write it, without a deployment. The preview calls a `PreviewProvider` function in the source code, which builds a simulated request. For the auxiliary function and the formats the preview renders, refer to [Preview deployment](/en/documentation/platform/functions/preview-deployment/).

---

## ChatGPT integration

The code editor calls the ChatGPT APIs, so code assistance runs inside the editor and not in a separate tab. The integration covers:

- Code explanation
- Code generation
- Code refactor
- Debugging

The integration uses credentials from your own OpenAI account, declared in the source code of the function. For the credentials and the editor commands, refer to [ChatGPT integration](/en/documentation/platform/functions/ai-integration/).

---

## Related resources

- [Quickstart](/en/documentation/platform/functions/quickstart.md): Reach the editor, write a function, and put it in the request path.
- [Preview deployment](/en/documentation/platform/functions/preview-deployment.md): Read the response of the function before it serves traffic.
- [ChatGPT integration](/en/documentation/platform/functions/ai-integration.md): Generate, refactor, and explain code without leaving the editor.
- [Build an API function with ChatGPT](/en/documentation/guides/application-development/functions-and-runtime/api-builder.md): A worked example that ends in a function saved from the editor.
- [Query usage data from Functions](/en/documentation/guides/platform/observability/query-functions-usage-data-with-graphql.md): Read back the compute time and the invocations an account has consumed.
- [No log output from a function](/en/documentation/platform/functions/troubleshooting.md#no-log-output-from-a-function): Where the output of `console.log` appears, and why it sometimes does not.
