# Migrate from ByteDance's API

> Move code written for ByteDance's own API to Kerox: keep the request body, wrap it, change the host and key, read the result the Kerox way.

ByteDance models take ByteDance's own request body when you add `"format": "native"`, so the parameters you already send stay as they are. What changes is around them: the host, the key, where `model` and the callback go, and how you get the result. Other models don't have this option: they take [Kerox's parameter names](https://kerox.ai/docs/models.md), which ByteDance models take too.

<a id="changes"></a>

## What to change
| In your ByteDance code | On Kerox |
| --- | --- |
| ByteDance's endpoint | `POST https://api.kerox.ai/v1/tasks`, for images and video alike |
| ByteDance's API key | A Kerox key: `Authorization: Bearer $KEROX_API_KEY` ([Quickstart](https://kerox.ai/docs/quickstart.md#key)) |
| `model`: ByteDance's model name | `model`: the Kerox model ID, such as `bytedance/seedream-5.5` ([Models](https://kerox.ai/docs/models.md)) |
| The rest of the body | Unchanged, inside `input`, with `"format": "native"` next to it |
| `callback_url` | `webhook_url`, at the top level next to `model` ([Webhooks](https://kerox.ai/docs/webhooks.md)) |
| The result in the response | The response has the task's `id` at once; poll `GET /v1/tasks/{id}` or wait for the webhook, then read the files in `outputs` ([Tasks](https://kerox.ai/docs/tasks.md#polling)) |

Some of ByteDance's parameters are handled differently:

- **Accepted and ignored**: `service_tier`, `priority`, `safety_identifier`. A body that has them works unchanged; they are not passed to the model and ByteDance's defaults apply.
- **Moved**: `callback_url` becomes the top-level `webhook_url`.
- **Remove them**: `execution_expires_after`, `response_format`, `stream`. A body that has them is refused with HTTP `400` `invalid_request`, and `param` names the field.

<a id="examples"></a>

## Before and after
An image request. `response_format` goes; the result is always a file URL in `outputs`.


```json
{
  "model": "<ByteDance model name>",
  "prompt": "a quiet coastal lighthouse at dusk",
  "size": "2K",
  "response_format": "url",
  "watermark": false
}
```
```json
{
  "model": "bytedance/seedream-5.5",
  "format": "native",
  "input": {
    "prompt": "a quiet coastal lighthouse at dusk",
    "size": "2K",
    "watermark": false
  }
}
```


A video request. `callback_url` moves out to `webhook_url`; `service_tier` can stay and is ignored.


```json
{
  "model": "<ByteDance model name>",
  "content": [{ "type": "text", "text": "a red fox running through fresh snow" }],
  "ratio": "16:9",
  "resolution": "720p",
  "duration": 5,
  "service_tier": "default",
  "callback_url": "https://your-app.example.com/webhooks/kerox"
}
```
```json
{
  "model": "bytedance/seedance-2.5",
  "format": "native",
  "webhook_url": "https://your-app.example.com/webhooks/kerox",
  "input": {
    "content": [{ "type": "text", "text": "a red fox running through fresh snow" }],
    "ratio": "16:9",
    "resolution": "720p",
    "duration": 5,
    "service_tier": "default"
  }
}
```


<a id="native"></a>

## Send it
The video request, sent. What each model takes in this format is its `input_schema` in `GET /v1/models/{id}`, and the ByteDance format section of its [model page](https://kerox.ai/docs/models.md).


```bash
curl -X POST https://api.kerox.ai/v1/tasks \
  -H "Authorization: Bearer $KEROX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "bytedance/seedance-2.5",
    "format": "native",
    "input": {
      "content": [
        { "type": "text", "text": "a red fox running through fresh snow" }
      ],
      "ratio": "16:9",
      "resolution": "720p",
      "duration": 5
    }
  }'
```
```python
import os
import requests

resp = requests.post(
    "https://api.kerox.ai/v1/tasks",
    headers={
        "Authorization": f"Bearer {os.environ['KEROX_API_KEY']}",
        "Content-Type": "application/json",
    },
    json={
        "model": "bytedance/seedance-2.5",
        "format": "native",
        "input": {
            "content": [
                {"type": "text", "text": "a red fox running through fresh snow"}
            ],
            "ratio": "16:9",
            "resolution": "720p",
            "duration": 5,
        },
    },
    timeout=30,
)
print(resp.json())
```
```javascript
const res = await fetch('https://api.kerox.ai/v1/tasks', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.KEROX_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    model: 'bytedance/seedance-2.5',
    format: 'native',
    input: {
      content: [
        { type: 'text', text: 'a red fox running through fresh snow' },
      ],
      ratio: '16:9',
      resolution: '720p',
      duration: 5,
    },
  }),
});
console.log(await res.json());
```


The response and everything after it are the same as for every task: see [Tasks & polling](https://kerox.ai/docs/tasks.md#polling).
