> For the documentation index, fetch https://sync.so/docs/llms.txt. Append .md to a page URL for Markdown. Documentation-search MCP: https://sync.so/docs/_mcp/server.

# List Generation Costs

GET https://api.sync.so/v2/usage/generations

List the recorded cost of every generation that finished in a time
range. Each item is the [Get Generation Costs](/docs/api-reference/api/generate-api/get-costs)
object plus `createdAt`, `finishedAt`, `model` and `apiKey`.

The range filters on `finishedAt` (`startTime` inclusive, `endTime`
exclusive), oldest first, so back-to-back ranges never overlap. Page
with `cursor` until `nextCursor` is null, keeping the same range.

Costs are usually recorded within 10 minutes of completion.
`totalCostUsd` is null while any part is pending or unavailable. See
[Export usage and costs](/docs/api-reference/guides/usage-export).

Reference: https://sync.so/docs/api-reference/api/generate-api/list-costs

## Authentication

- `x-api-key` header (required) — API Key authentication via header

## Servers

- `https://api.sync.so` (Default, default)
- `https://dev-api.sync.so` (dev)
- `http://localhost:3001` (local)

## Request

### Query parameters

- `startTime` (datetime, required) — Start of the range, inclusive. UTC ISO 8601 date-time, such as 2026-11-12T00:00:00Z.
- `endTime` (datetime, required) — End of the range, exclusive. UTC ISO 8601 date-time. Must be after startTime.
- `limit` (integer, optional) — Items per page, 1 to 500. Defaults to 100.
- `cursor` (string, optional) — The nextCursor from the previous page. Send it with the same startTime and endTime.

## Response

### 200

- `items` (list of GenerationCostsListItem, required)
- `nextCursor` (string, required, nullable) — Pass as `cursor` with the same `startTime` and `endTime` to get the next page. Null on the last page.

## Errors

### 400 Bad Request Error

Bad Request - Invalid input or unsupported model

- `message` (GenerationErrorMessage, required) — A message describing the error.
- `statusCode` (double, required) — The type of error that occurred.
- `errorCode` (string, optional) — Stable, machine-readable error code (e.g. project_not_found, voice_not_found, concurrency_limit_reached). Branch your error handling on this, not on the message text. The full catalog of codes with messages and suggested fixes is served unauthenticated at GET /v2/errors.
- `suggestion` (string, optional) — A suggested fix an agent can act on.
- `field` (string, optional) — The request field the error refers to, when the failure is tied to a specific field (e.g. projectId, voiceId, input[].assetId).
- `docsUrl` (string, optional) — Link to the documentation page for the failing operation.
- `billingUrl` (string, optional) — Billing page for resolving a payment, plan, or allowance issue, when applicable.
- `requestId` (string, optional) — Present on unexpected 500 responses. Include it when contacting support so the failing request can be located directly.
- `generationId` (string, optional) — Original generation ID when available for an uncertain keyed submission or a DUPLICATE_SUBMISSION. Poll this ID; do not create another action to bypass IDEMPOTENCY_OUTCOME_UNKNOWN.
- `dialogueEditSection` (DialogueEditRetimeFailureSection, optional) — For dialogue_edit_removal_too_large: the section to change, when it can be identified. Create a new dialogue edit preview before submitting again.
- `voiceId` (string, optional) — For voice\_clone\_pending, the pending clone ID. Poll GET /v2/voices/\{voiceId} instead of submitting another clone.
- `lineNumber` (integer, optional) — For batch creation, on dialogue edit refusals only: the 1-based line of the refused record, counting non-empty JSONL lines. With a `rows` body, line N is `rows[N-1]`. Other record errors name the line only in `message`.

### 401 Unauthorized Error

Unauthorized - Invalid or missing authentication

- `message` (GenerationErrorMessage, required) — A message describing the error.
- `statusCode` (double, required) — The type of error that occurred.
- `errorCode` (string, optional) — Stable, machine-readable error code (e.g. project_not_found, voice_not_found, concurrency_limit_reached). Branch your error handling on this, not on the message text. The full catalog of codes with messages and suggested fixes is served unauthenticated at GET /v2/errors.
- `suggestion` (string, optional) — A suggested fix an agent can act on.
- `field` (string, optional) — The request field the error refers to, when the failure is tied to a specific field (e.g. projectId, voiceId, input[].assetId).
- `docsUrl` (string, optional) — Link to the documentation page for the failing operation.
- `billingUrl` (string, optional) — Billing page for resolving a payment, plan, or allowance issue, when applicable.
- `requestId` (string, optional) — Present on unexpected 500 responses. Include it when contacting support so the failing request can be located directly.
- `generationId` (string, optional) — Original generation ID when available for an uncertain keyed submission or a DUPLICATE_SUBMISSION. Poll this ID; do not create another action to bypass IDEMPOTENCY_OUTCOME_UNKNOWN.
- `dialogueEditSection` (DialogueEditRetimeFailureSection, optional) — For dialogue_edit_removal_too_large: the section to change, when it can be identified. Create a new dialogue edit preview before submitting again.
- `voiceId` (string, optional) — For voice\_clone\_pending, the pending clone ID. Poll GET /v2/voices/\{voiceId} instead of submitting another clone.
- `lineNumber` (integer, optional) — For batch creation, on dialogue edit refusals only: the 1-based line of the refused record, counting non-empty JSONL lines. With a `rows` body, line N is `rows[N-1]`. Other record errors name the line only in `message`.

### 503 Service Unavailable Error

Service Unavailable - A sync. service or provider is temporarily unavailable. Retry after Retry-After. The errorCode says what failed, such as elevenlabs_service_unavailable or controller_dependency_error. generation_admission_paused means new generations are paused for maintenance; generation_admission_unavailable means the API can't confirm it is accepting them. IDEMPOTENCY_OUTCOME_UNKNOWN means it isn't yet known whether a keyed create was accepted; retry with the same key and payload. See [Error Handling](/docs/developer-guides/error-handling).

- `message` (GenerationErrorMessage, required) — A message describing the error.
- `statusCode` (double, required) — The type of error that occurred.
- `errorCode` (string, optional) — Stable, machine-readable error code (e.g. project_not_found, voice_not_found, concurrency_limit_reached). Branch your error handling on this, not on the message text. The full catalog of codes with messages and suggested fixes is served unauthenticated at GET /v2/errors.
- `suggestion` (string, optional) — A suggested fix an agent can act on.
- `field` (string, optional) — The request field the error refers to, when the failure is tied to a specific field (e.g. projectId, voiceId, input[].assetId).
- `docsUrl` (string, optional) — Link to the documentation page for the failing operation.
- `billingUrl` (string, optional) — Billing page for resolving a payment, plan, or allowance issue, when applicable.
- `requestId` (string, optional) — Present on unexpected 500 responses. Include it when contacting support so the failing request can be located directly.
- `generationId` (string, optional) — Original generation ID when available for an uncertain keyed submission or a DUPLICATE_SUBMISSION. Poll this ID; do not create another action to bypass IDEMPOTENCY_OUTCOME_UNKNOWN.
- `dialogueEditSection` (DialogueEditRetimeFailureSection, optional) — For dialogue_edit_removal_too_large: the section to change, when it can be identified. Create a new dialogue edit preview before submitting again.
- `voiceId` (string, optional) — For voice\_clone\_pending, the pending clone ID. Poll GET /v2/voices/\{voiceId} instead of submitting another clone.
- `lineNumber` (integer, optional) — For batch creation, on dialogue edit refusals only: the 1-based line of the refused record, counting non-empty JSONL lines. With a `rows` body, line N is `rows[N-1]`. Other record errors name the line only in `message`.

## Types

### GenerationCostsListItem

The recorded costs of one generation, with when it ran, its model and the API key that created it.

- `apiKey` (GenerationCostsApiKey, required, nullable) — API key that created the generation. Null for a generation made in Studio.
- `availability` (enum, required)
  - Allowed values: `complete`, `pending`, `partial`, `unavailable`
- `components` (list of CostComponent, required)
- `createdAt` (datetime, required) — When the generation was created.
- `currency` (string, required) — Always USD.
- `excludedCosts` (list of string, required) — Costs excluded from this response.
- `finishedAt` (datetime, required) — When the generation finished. The time range filters on this value.
- `generationId` (string, required)
- `generationStatus` (string, required)
- `knownSubtotalUsd` (string, required) — Sum of available amounts. This may be less than the final total.
- `model` (string, required) — Model that ran the generation.
- `retryAfterSeconds` (integer, required, nullable) — Suggested wait before checking again, when provided.
- `totalCostUsd` (string, required, nullable) — Total as a decimal USD string. Null if any component is pending or unavailable.

### GenerationErrorMessage

A message describing the error.

- string
- list of string

### DialogueEditRetimeFailureSection

The dialogue-edit section that removes too much speech to stay in sync.

- `slotIndex` (integer, required) — Zero-based index of the section in the preview's `resultSlots`.
- `sourceStartMs` (integer, optional) — Start of the section in the source video, in absolute milliseconds.
- `sourceDurationMs` (integer, optional) — Length of the section in the source video, in milliseconds.

### GenerationCostsApiKey

- `id` (string, required)
- `name` (string, required, nullable) — Name given to the key. Null if it has none.
- `mask` (string, required, nullable) — First and last characters of the key, as shown in Studio, such as `sk-AB...wxyz`. Use it to recognize a key that has no name.

### CostComponent

- `type` (enum, required)
  - Allowed values: `lipsync`, `dubbing`, `speech_synthesis`
- `operationId` (string, required, nullable)
- `status` (enum, required)
  - Allowed values: `recorded`, `pending`, `unavailable`, `not_charged`
- `amountUsd` (string, required, nullable)
- `credits` (string, required, nullable) — Credit quantity as a decimal integer string, when applicable.
- `valueBasis` (enum, required, nullable) — Whether the amount represents credit face value, metered usage, or no charge.
  - Allowed values: `credit_face_value`, `metered_usage`, `none`
- `quantity` (double, required, nullable)
- `unit` (enum, required)
  - Allowed values: `frames`, `seconds`
- `unitRateUsd` (string, required, nullable)
- `source` (enum, required, nullable)
  - Allowed values: `credit_ledger`, `recorded_usage`, `billing_context`
- `reason` (string, required, nullable)

## Examples

**Response**

```json
{
  "items": [
    {
      "apiKey": {
        "id": "6f4e5e34-399e-4e0d-82a2-f624a6ba9fd8",
        "name": "production",
        "mask": "sk-AB...wxyz"
      },
      "availability": "complete",
      "components": [
        {
          "type": "lipsync",
          "operationId": "6bb46001-dd37-4f4d-908a-54bd67c4dc55",
          "status": "recorded",
          "amountUsd": "0.79950",
          "credits": null,
          "valueBasis": "metered_usage",
          "quantity": 150,
          "unit": "frames",
          "unitRateUsd": "0.00533",
          "source": "recorded_usage",
          "reason": null
        }
      ],
      "createdAt": "2026-11-12T08:14:03.120Z",
      "currency": "USD",
      "excludedCosts": [
        "tax",
        "subscription_fees",
        "external_provider_charges",
        "account_level_adjustments"
      ],
      "finishedAt": "2026-11-12T08:15:41.007Z",
      "generationId": "6bb46001-dd37-4f4d-908a-54bd67c4dc55",
      "generationStatus": "COMPLETED",
      "knownSubtotalUsd": "0.79950",
      "model": "sync-3",
      "retryAfterSeconds": null,
      "totalCostUsd": "0.79950"
    }
  ],
  "nextCursor": "0d7f5b4e-2a1c-4c3e-9b8a-7e6d5c4b3a21"
}
```

**SDK Code**

```python
import requests

url = "https://api.sync.so/v2/usage/generations"

querystring = {"endTime":"2026-11-13T00:00:00Z","limit":"500","startTime":"2026-11-12T00:00:00Z"}

headers = {"x-api-key": "<apiKey>"}

response = requests.get(url, headers=headers, params=querystring)

print(response.json())
```

```javascript
const url = 'https://api.sync.so/v2/usage/generations?endTime=2026-11-13T00%3A00%3A00Z&limit=500&startTime=2026-11-12T00%3A00%3A00Z';
const options = {method: 'GET', headers: {'x-api-key': '<apiKey>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.sync.so/v2/usage/generations?endTime=2026-11-13T00%3A00%3A00Z&limit=500&startTime=2026-11-12T00%3A00%3A00Z"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("x-api-key", "<apiKey>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.sync.so/v2/usage/generations?endTime=2026-11-13T00%3A00%3A00Z&limit=500&startTime=2026-11-12T00%3A00%3A00Z")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<apiKey>'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.sync.so/v2/usage/generations?endTime=2026-11-13T00%3A00%3A00Z&limit=500&startTime=2026-11-12T00%3A00%3A00Z")
  .header("x-api-key", "<apiKey>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.sync.so/v2/usage/generations?endTime=2026-11-13T00%3A00%3A00Z&limit=500&startTime=2026-11-12T00%3A00%3A00Z', [
  'headers' => [
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.sync.so/v2/usage/generations?endTime=2026-11-13T00%3A00%3A00Z&limit=500&startTime=2026-11-12T00%3A00%3A00Z");
var request = new RestRequest(Method.GET);
request.AddHeader("x-api-key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["x-api-key": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sync.so/v2/usage/generations?endTime=2026-11-13T00%3A00%3A00Z&limit=500&startTime=2026-11-12T00%3A00%3A00Z")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```