> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://onepin.ai/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://onepin.ai/docs/_mcp/server.

# Get Voice Preview

GET https://api.onepin.ai/api/v1/voices/{voice_id}/preview

Fetch ready-to-play preview audio for one voice in one language.

Returns the voice's `name`, the preview's `locale`, the `model` it was
synthesized with, its stored `content_type`, and a `sample_url` — a
time-limited presigned URL valid for 1 hour; regenerate it by calling this
endpoint again rather than caching it long-term. Pass `model` to prefer a
specific TTS model; a preview from another model is still returned when
that model has none.

`language` accepts a bare family (`ko`, `en`) as well as an exact locale
(`ko-kr`, `en-gb`). A bare family expands to every supported locale in it,
and which region wins is deterministic but arbitrary — so the response
echoes the `locale` actually served. Read `locale`, never the request
parameter, when labelling what the caller is hearing.

404 means no preview audio has been generated for this voice in that
locale — NOT that the voice cannot speak it. `supported_languages` on the
voice is the claim about what it can speak; `preview_locales` is the list
of locales this endpoint will succeed for. 404 is also returned when the
voice does not exist, is not accessible to the caller's workspace, or is a
platform voice from a provider that is not available to your account.

Reference: https://onepin.ai/docs/reference/api-reference/voices/preview

## Authentication

- `Authorization` header (bearer token, required) — Clerk JWT token
- `Authorization` header (bearer token, required) — Onepin live API key (`op_live_...`). Test and public keys are reserved in Phase 1.

## Servers

- `https://api.onepin.ai` (prod, default)
- `https://dev-api.onepin.ai` (dev)

## Request

### Path parameters

- `voice_id` (string, required)

### Query parameters

- `language` (enum, required) — BCP-47 language code, e.g. en-us, ko-kr
  - Allowed values: `de`, `de-de`, `en`, `en-gb`, `en-us`, `es`, `es-es`, `es-mx`, `fr`, `fr-fr`, `ja`, `ja-jp`, `ko`, `ko-kr`, `pt`, `pt-br`, `pt-pt`, `zh`, `zh-cn`
- `model` (string, optional, nullable) — TTS model id, e.g. sonic-2

### Headers

- `X-Workspace-Id` (string, optional, nullable)

## Response

### 200

Successful Response

- `data` (VoicePreviewOut, required)
- `meta` (Meta, required)

## Errors

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### VoicePreviewOut

- `name` (string, required) — The voice's catalog name, echoed so a caller holding only an id can label what it is about to play. A client that renders the sample as a player shows this to the user, who never sees the id the request was made with.
- `locale` (string, required) — The actual regioned locale of the selected preview tuple, not a reflection of the request's `language` parameter. A bare-family request like `?language=en` expands to both `en-us` and `en-gb`, so without this field the caller cannot know which one they are hearing.
- `model` (string, required) — The TTS model the preview was synthesized with.
- `sample_url` (string, required) — Time-limited presigned URL for the audio preview sample. Valid for 1 hour; regenerate by fetching the preview again.
- `content_type` (string, optional, nullable) — The selected row's stored `preview_content_type`, read from the database row — not a guarantee that the object in S3 is playable. May be null.

### Meta

- `request_id` (string, required)
- `timestamp` (datetime, required)

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)
- `input` (any, optional)
- `ctx` (ValidationErrorCtx, optional)

### ValidationErrorLocItems

- string
- integer

### ValidationErrorCtx

## Examples

**Response**

```json
{
  "data": {
    "name": "string",
    "locale": "string",
    "model": "string",
    "sample_url": "string",
    "content_type": "string"
  },
  "meta": {
    "request_id": "string",
    "timestamp": "2024-01-15T09:30:00Z"
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.onepin.ai/api/v1/voices/voice_id/preview"

querystring = {"language":"de"}

headers = {"Authorization": "Bearer <token>"}

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

print(response.json())
```

```javascript
const url = 'https://api.onepin.ai/api/v1/voices/voice_id/preview?language=de';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

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.onepin.ai/api/v1/voices/voice_id/preview?language=de"

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

	req.Header.Add("Authorization", "Bearer <token>")

	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.onepin.ai/api/v1/voices/voice_id/preview?language=de")

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

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

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.onepin.ai/api/v1/voices/voice_id/preview?language=de")
  .header("Authorization", "Bearer <token>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.onepin.ai/api/v1/voices/voice_id/preview?language=de', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.onepin.ai/api/v1/voices/voice_id/preview?language=de");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.onepin.ai/api/v1/voices/voice_id/preview?language=de")! 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()
```