
# Synthorai Provider

[Synthorai](https://synthorai.io) is an AI gateway that provides access to models from multiple providers through an OpenAI-compatible API. You can use its Chat Completions endpoint with the AI SDK through the `@ai-sdk/openai-compatible` module.

## Setup

The Synthorai provider is available via the `@ai-sdk/openai-compatible` module as it is compatible with the OpenAI API. You can install it with:

<InstallPackages packages="@ai-sdk/openai-compatible" />

## Provider Instance

To use Synthorai, create a custom provider instance with the `createOpenAICompatible` function from `@ai-sdk/openai-compatible`:

```ts
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';

const synthorai = createOpenAICompatible({
  name: 'synthorai',
  baseURL: 'https://synthorai.io/v1',
  apiKey: process.env.SYNTHORAI_API_KEY,
});
```

<Note>
  Follow the [Synthorai quickstart](https://synthorai.io/docs/quickstart/) to
  create an API key. Make sure to set the `SYNTHORAI_API_KEY` environment
  variable with your API key.
</Note>

## Language Models

You can create Synthorai models using the provider instance. The first argument is a model ID from the [model catalog](https://synthorai.io/models/), for example `claude-fable-5`.

```ts
const model = synthorai('claude-fable-5');
```

### Example

You can use Synthorai language models to generate text with the `generateText` function:

```ts
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
import { generateText } from 'ai';

const synthorai = createOpenAICompatible({
  name: 'synthorai',
  baseURL: 'https://synthorai.io/v1',
  apiKey: process.env.SYNTHORAI_API_KEY,
});

const { text } = await generateText({
  model: synthorai('claude-fable-5'),
  prompt: 'Tell me about yourself in one sentence.',
});

console.log(text);
```

Synthorai language models can also generate text in a streaming fashion with the `streamText` function:

```ts
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
import { streamText } from 'ai';

const synthorai = createOpenAICompatible({
  name: 'synthorai',
  baseURL: 'https://synthorai.io/v1',
  apiKey: process.env.SYNTHORAI_API_KEY,
});

const result = streamText({
  model: synthorai('claude-fable-5'),
  prompt: 'Write a short haiku about routing.',
});

for await (const textPart of result.textStream) {
  process.stdout.write(textPart);
}
```

See the [Synthorai documentation](https://synthorai.io/docs/) for endpoint details and model-specific capabilities.


## Navigation

- [Writing a Custom Provider](/providers/openai-compatible-providers/custom-providers)
- [LM Studio](/providers/openai-compatible-providers/lmstudio)
- [NVIDIA NIM](/providers/openai-compatible-providers/nim)
- [Clarifai](/providers/openai-compatible-providers/clarifai)
- [Heroku](/providers/openai-compatible-providers/heroku)
- [NEAR AI Cloud](/providers/openai-compatible-providers/nearai)
- [Synthorai](/providers/openai-compatible-providers/synthorai)


[Full Sitemap](/sitemap.md)
