---
agent:
  instructions: "Search the site by keyword or question. The search API returns Markdown."
  endpoint: "https://platform.invideo.io/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Test your integration

> Try successful requests, errors, and slow replies with free test models.

Use the test models to see how your app handles success, errors, and interruptions before you use a paid model. Ask Platform support to enable them for your workspace. Use your usual Platform API key. Every test-model request costs $0.

| Model | What it returns |
| --- | --- |
| `test-chat` | A text reply |
| `test-image` | A PNG image |
| `test-video` | An MP4 video |
| `test-audio` | An MP3 audio file |

## Choose what the test model does

Use `test_scenario` to tell the model what to do. Leave it out for a successful request. The JSON text you send for the scenario can be up to 1,024 bytes. For chat, that includes the outer `{"test_scenario": ...}` wrapper.

| Field | What it does |
| --- | --- |
| `outcome` | Choose how the request ends. `ok` succeeds and is the default. `provider_400` acts like a rejected request, `provider_429` like a rate limit, and `provider_503` like a service outage. `timeout` makes the call wait until it times out, `malformed` sends a broken response, and `disconnect` closes the connection. For example, use `"outcome": "provider_429"` to test your rate-limit handling. |
| `attempts` | List one to four outcomes in order, in place of `outcome`. For example, `["provider_503", "provider_429", "ok"]` gives the first try a service error, the second a rate limit, and the third a success. If there are more tries, the last outcome repeats. Your usual retry rules still apply. |
| `stage` | For image, video, and audio, choose when the outcome and first reply delay apply. Use `submit` to start the job (the default), `status` to check progress, or `download` to fetch the file. For example, use `"stage": "download"` to test a failed download. |
| `first_byte_ms` | Wait before the reply starts. Use 0 to 10,000 milliseconds. For example, `"first_byte_ms": 1500` waits a second and a half. |
| `chunk_gap_ms` | For streamed chat replies, wait between pieces of text. Use 0 to 10,000 milliseconds. For example, `"chunk_gap_ms": 250` waits a quarter of a second between pieces. |
| `output` | Choose the result size. For image, video, and audio, use `"output": "small"` (the default) or `"output": "large"`. For chat, `"output": {"chunks": 4, "text_bytes": 200}` streams 200 bytes in four pieces. Use 1 to 32 pieces (default 4). The byte count must be at least the number of pieces and at most 8,192. |
| `after_chunks` | For a chat stream that disconnects, choose how many pieces arrive first. Use a whole number from 0 up to one fewer than `output.chunks`. For example, `"after_chunks": 3` with four pieces drops the connection after the third. |

You get the same kind of error, streamed event, or job status your chosen API format uses for other models. Check the final status and $0 charge with the [Requests API](/docs/requests).

## Chat

Use `test-chat` with any [chat format](/docs/sdks/llm). Put the scenario in the system message or instructions as JSON text, wrapped in a `test_scenario` object.

| Format | Where to put the JSON text |
| --- | --- |
| OpenAI Chat Completions and compatible formats | `messages[].content` on a message with `role: "system"` |
| OpenAI Responses | `instructions` |
| Anthropic Messages and MiniMax Messages | `system` |
| Gemini | `systemInstruction.parts[].text` |

### Example: Drop a chat stream after three pieces

This request sends three pieces of the reply and then closes the connection before the fourth.

```bash
curl -N https://platform-api.invideo.io/v1/chat/completions \
  -H "Authorization: Bearer $INVIDEO_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @- <<'JSON'
{
  "model": "test-chat",
  "stream": true,
  "messages": [
    {
      "role": "system",
      "content": "{\"test_scenario\":{\"outcome\":\"disconnect\",\"output\":{\"chunks\":4,\"text_bytes\":32},\"after_chunks\":3}}"
    },
    {"role": "user", "content": "Hello"}
  ]
}
JSON
```

## Image, video, and audio

Send the request to `POST /v1/request`. Set `mode` to `generate` for `test-image` or `test-video`, and `speech` for `test-audio`. Put the scenario JSON string in `input.test_scenario`. If you use a [provider format](/docs/sdks), pass `test_scenario` as a model input where that format accepts extra inputs.

### Example: Fail an image job at download

This request starts an image job. The failure happens when Platform tries to fetch the finished file. Take the request ID from the first response and [check the job status](/docs/requests).

```bash
curl https://platform-api.invideo.io/v1/request \
  -H "Authorization: Bearer $INVIDEO_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @- <<'JSON'
{
  "model": "test-image",
  "mode": "generate",
  "input": {
    "prompt": "A red square",
    "test_scenario": "{\"stage\":\"download\",\"outcome\":\"provider_400\"}"
  }
}
JSON
```
