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

# Background Mode

### What is background mode?

In background mode, you submit a chat request without waiting for the model to finish. Retrieve the result later. This is useful for long-running tasks such as image generation, complex reasoning, deep research, or multi-turn conversations.

> [!NOTE]
>
> Models and tasks that often take longer include:
>
> * Reasoning models set to a high reasoning effort
> * Gemini Banana models that generate images in chat
> * Chat models working on lengthy image analysis, video understanding, or document tasks
> * [Chat models](https://geekai.co/models?platform=perplexity) with the `sonar` ID prefix (these require web search)
> * Web search chat models with `search` in their IDs
> * Deep research reasoning models with `research` in their IDs
> * Chat models using tools such as [search](https://docs.geekai.co/en/docs/chat/web_search.md) (`web_search`) or [image generation](https://docs.geekai.co/en/docs/chat/draw.md) (`image_generation`)
> * Other chat models with built-in web search enabled or external search tools in use
> * Other chat models that support image generation, voice, web fetching, document chat, or video analysis
>
> You can also use background mode with other chat models if they respond slowly.
>
> Background mode is available only for non-streaming Chat Completions requests. Image and video models offer their own asynchronous modes.

### Enable background mode

Set `background` to `true` in your chat request:

```bash curl theme={null}
curl --location --request POST 'https://geekai.co/api/v1/chat/completions' \
--header 'Authorization: Bearer $GEEKAI_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "gemini-nano-banana-2.1",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "Create an image of a Nano Banana dish in an upscale restaurant with a GeekAI theme."
          }
        ]
      }
    ],
    "background": true
}'
```

```bash go theme={null}
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"net/http"
)

func main() {
	requestBody := map[string]interface{}{
		"model": "gemini-nano-banana-2.1",
		"messages": []interface{}{
            map[string]interface{}{
                "role": "user",
                "content": []interface{}{
                  map[string]interface{}{
                    "type": "text",
                    "text": "Create an image of a Nano Banana dish in an upscale restaurant with a GeekAI theme.",
                  },
                },
                "background": true
            },
        }
	}

	jsonData, err := json.Marshal(requestBody)
	if err != nil {
		panic(err)
	}

	client := &http.Client{}
	req, err := http.NewRequest("POST", "https://geekai.co/api/v1/chat/completions", bytes.NewBuffer(jsonData))
	if err != nil {
		panic(err)
	}

	req.Header.Set("Authorization", "Bearer $GEEKAI_API_KEY")
	req.Header.Set("Content-Type", "application/json")

	resp, err := client.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	body, err := io.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}

	fmt.Println(string(body))
}
```

Background mode works only with non-streaming Chat Completions requests. Setting both `stream` and `background` to `true` causes the request to fail:

```json theme={null}
{
    "message": "only non-stream chat support background mode"
}
```

### Retrieve a background result

The initial response contains a unique `id` that identifies the chat task:

```json theme={null}
{
    "id": "1498e730-e3c7-48a5-b748-9d2d3e7c525b",
    "status": "pending",
    "created": 1794888275,
    "model": "gemini-nano-banana-2.1",
    "object": "chat.completion"
}
```

Use this `id` with the [chat result endpoint](https://docs.geekai.co/en/api/chat/result.md) to check the task status and retrieve the result:

```bash theme={null}
curl --location --request GET 'https://geekai.co/api/v1/chat/{id}' \
--header 'Authorization: Bearer $GEEKAI_API_KEY'
```

Replace `{id}` in the endpoint path with the task `id` from the initial response (`1498e730-e3c7-48a5-b748-9d2d3e7c525b` in this example). The query can return the following statuses:

* `pending`: The task is queued.
* `running`: The task is being processed.
* `succeed`: The task completed successfully.

On success, the result has the same format as a non-background Chat Completions response:

```json theme={null}
{
    "id": "1498e730-e3c7-48a5-b748-9d2d3e7c525b",
    "status": "succeed",
    "created": 1794917075,
    "completed": 1794917097,
    "choices": [
        {
            "index": 0,
            "message": {
                "role": "assistant",
                "content": "\n![](https://static.geekai.co/image/2026/11/17/d95ab81d4c2e267c5b2988205433ed4d.png)\n",
                "reasoning_content": "**Refining Nanotech Dessert**\n\nI'm working on elaborating the intricate details of a molecular gastronomy dessert, specifically focusing on how to represent the \"Nano Banana\" concept through microscopic edible elements and futuristic plating. My current focus is on integrating \"GeekAI\" themes via cybernetic patterns and subtle digital displays within the upscale restaurant setting.\n\n**Focusing on AI Integration**\n\nMy efforts are now centered on refining the integration of the \"GeekAI\" theme into the presentation of the \"Nano Banana\" dish within the upscale restaurant. I am exploring how to visually communicate advanced AI curation through futuristic plating and subtle thematic elements.\n\n**Developing Futuristic Presentation**\n\nI'm currently focused on developing the visual representation of the \"Nano Banana\" dish, emphasizing its miniature, high-tech elements. My work is concentrating on how to best integrate the \"GeekAI\" theme into the upscale restaurant environment through lighting and subtle digital cues.\n\n**Enhancing Edible Tech Elements**\n\nMy current focus is on detailing the microscopic, tech-inspired components of the \"Nano Banana\" dish. I am exploring how to best represent edible nanotech and integrate the \"GeekAI\" theme through subtle yet striking visual elements in the upscale restaurant setting.\n\n**Refining Nanobanan Elements**\n\nI'm currently focusing on evolving the \"nano banana\" components. The goal is to transform them from simple miniature fruit representations into sophisticated, molecular gastronomy-style edible art pieces. I envision them as delicate, luxurious dessert elements, perhaps with gold dust or glaze, that align with the high-end dining aesthetic while retaining the GEEK AI theme.\n\n",
                "image": {
                    "url": "https://static.geekai.co/image/2026/11/17/d95ab81d4c2e267c5b2988205433ed4d.png"
                }
            },
            "finish_reason": "stop"
        }
    ],
    "model": "gemini-nano-banana-2.1",
    "object": "chat.completion",
    "usage": {
        "prompt_tokens": 24,
        "completion_tokens": 2399,
        "total_tokens": 2423,
        "billed_units": 2,
        "prompt_tokens_details": {
            "text_tokens": 24
        },
        "completion_tokens_details": {
            "text_tokens": 1120,
            "image_tokens": 1120,
            "reasoning_tokens": 1279
        },
        "billed_units_details": {
            "image_units": 2
        }
    }
}
```

Deserialize the JSON just as you would for a non-streaming chat completion.

> [!NOTE]
>
> Results are retained for 7 days by default and then deleted automatically. Retrieve and save them before they expire.

If the task fails, the error has the same format as a non-streaming Chat Completions error. Use its code and message to diagnose the failure.


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