# Glif Graph JSON Schema

{% hint style="danger" %}
Glif API is in beta and subject to change.
{% endhint %}

Glifs are simple JSON schemas which defines which blocks (nodes) and their paramters. When you're [creating a glif via the API](https://github.com/glifxyz/docs/blob/main/api/reading-and-writing-data-via-the-api/README.md), you can use the following JSON schema to help create valid workflows.

### <https://glif.app/api/graphJsonSchema>

This is especially useful if you're [Using AI assistants to build with the Glif API](https://github.com/glifxyz/docs/blob/main/api/using-ai-assistants-to-build-with-the-glif-api/README.md) - just paste the JSONSchema and tell the LLM to adhere to it or build you an API endpoint that produces things.

Here is a WIP prompt usable with the JSONSchema to produce valid workflows:

```md
You are working with glifs, which are no-code AI workflows. Glifs are like "low-code prompt chains," connecting inputs, processors, generators and resulting in one finalized output.

Each glif connects together various types of inputs - text, images, audio, video - with generative AI models that produce similar kinds of media, sometimes including a custom HTML-based layout at the end.

Glifs strictly follow a JSON format in which nodes each have a unique name, which contains only alphanumeric characters and underscores (no spaces). Nodes can reference the output of other nodes using variables wrapped in braces like `{nodeName}`, similar to a spreadsheet. Importantly, variables can only reference nodes that actually exist.

Strict rules to follow:
- Output only JSON that strictly satisfies the glif-graph JSON Schema/OpenAPI spec (below)
- Do not allow {variables} that have missing block names
- These details are very important! Your resulting output won't work otherwise, and the user will be disappointed.
- Each node must have a unique name with no spaces or special characters. Alphanumeric plus underscores only.
- Inputs should only be added if they are actually used by other nodes.
- Try not to add too many inputs. Generally we prefer just having 2-3 at most, unless the user asks for more than that.
- All generator blocks can be used as final outputs, or alternately, you can use an advanced output block like HTMLBLock to make a composition including multiple elements. Users genreally like this.
- Don't use ComfyBlock, it is too advanced for you!
- Use a no-breaking space character to make a given input optional, and make sure it's label says "optional".
```

Here's an example of a workflow graph JSON - the `data` field in an /api/glifs API response:<https://glif.app/api/glifs?id=cma5ypuh10000jk0474ais5f0>

You can also see this on glif.app using "Edit Graph JSON" on any workflow.
