> ## Documentation Index
> Fetch the complete documentation index at: https://docs.opengame.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Portraits

> A player's OG portrait as a transparent PNG, drawn from their look, to show next to a name or load as a texture in your game.

A portrait is the head of a player's OG as a transparent PNG. A game can show it next to a name or load it as a texture.

[Authentication](https://docs.opengame.io/api-reference/authentication.md) covers each credential, and [errors](https://docs.opengame.io/api-reference/errors.md) covers the JSON error body.

## Draw a player's portrait

`GET https://opengame.io/api/avatars/{look}/portrait`

**Authentication:** None.

The head of an OG as a transparent PNG, as OpenGame shows it next to a name. The address is made only from the look recipe (`og.player.avatar.look`, or `portraitUrl` in `@opengamehq/sdk/avatar`), so it identifies no player and the image at one address stays the same. Each response includes `Access-Control-Allow-Origin: *` and `Cross-Origin-Resource-Policy: cross-origin`, so a game on another origin can show it or upload it as a WebGL texture.

### Parameters

#### Path

**look** `string` *required*

The look recipe: `shape.eyes.color`, then the optional accessory, identity, facial hair and hair colors. At most 125 characters. Matches `^[a-z]{1,16}(\.[a-z]{1,16}){2,7}$`. Example: `panda.dots.tangerine.crown`.

#### Query

**size** `integer` (default: 256)

One of `64`, `128`, `256` or `512`. Width and height in pixels. Any other number is redirected to the next listed size up, or to the largest when it is larger. A missing or malformed size is redirected to 256.

**theme** `string` (default: light)

One of `light` or `dark`. `dark` picks the inks OpenGame shows on a dark page, which turns the Auto color (`mono`) white. Any other value, or none, is redirected to `light`.

**v** `integer` (default: 2)

Only `2`. The drawing version. An old or missing one is redirected to the current one, 2.

### Request

```bash cURL theme={"system"}
curl --location --output portrait.png \
  --url 'https://opengame.io/api/avatars/panda.dots.tangerine.crown/portrait?size=128'
```

### Response 200

The portrait, sent as `image/png` with `Cache-Control: public, max-age=31536000, s-maxage=31536000, immutable`. Only an address with all 3 query parameters, in the order `size`, `theme`, `v`, as `portraitUrl` writes it, gets the image.

### Response 307

Redirects to the canonical address with `size`, `theme` and `v`; follow it. Sent when the request spells the look another way, names an unlisted size, or omits a parameter. A browser and a texture loader follow it on their own; curl needs `--location`.

#### Headers

**Location** `string`

The canonical address, relative to [https://opengame.io](https://opengame.io). Example: `/api/avatars/circle.classic.black/portrait?size=256&theme=light&v=2`.

### Errors

| Status | Meaning |
| - | - |
| 404 | Not a look OpenGame can draw: an unknown shape, eyes, color or accessory, or a malformed recipe. The response has no body. Show your default character. |
| 429 | This address asked for too many new portraits in the last hour. The body is JSON with `error`, and `Retry-After` gives the seconds to wait. Show your default character until then. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.