> For the complete documentation index, see [llms.txt](https://dazhizhong.gitbook.io/pixray-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dazhizhong.gitbook.io/pixray-docs/quickstart/generating-an-image.md).

# Generating an Image

For the pixray module, the simplest case for generation looks like this:

```python
import pixray
pixray.reset_settings()
pixray.add_settings(prompts="hellfire burning")
settings = pixray.apply_settings()
pixray.do_init(settings)
pixray.do_run(settings)
```

Now, what did the code do?

The first line imported pixray, which was added to the system path previously during installation.

Then, it reset its settings, clearing any previous settings, if any.

Then, through the `pixray.add_settings()` method, we can pass in arguments that pixray can use to guide and specify how to generate those images. More possible arguments and how to use them, as well as its purpose and effect can be found in [Docs](/pixray-docs/docs/primary-settings.md)

We generate all settings, including defaults, in a namespace, which can be saved and used to initialize pixray again. (WARNING: this actually does not do this, and apply\_settings actually modifies globals oof ouch)

Now with `settings`, we can initialize pixray's session (global) settings, and run pixray based on them.

By default, the WxH for an image is 384x208, and it runs for 250 iterations on VQGAN. Expected output may look like this:

![](/files/nfWA4XO1kvybtsSy1466)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://dazhizhong.gitbook.io/pixray-docs/quickstart/generating-an-image.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
