|
| 1 | +--- |
| 2 | +title: Poe |
| 3 | +description: Poe Provider for the AI SDK |
| 4 | +--- |
| 5 | + |
| 6 | +# Poe |
| 7 | + |
| 8 | +[Poe](https://poe.com) is a unified AI platform that provides access to models from Anthropic, OpenAI, Google, and other providers through a single API. The Poe provider for the AI SDK enables seamless integration with all these models: |
| 9 | + |
| 10 | +- **Multi-Provider Access**: Use Anthropic, OpenAI, Google, and other models with a single API key |
| 11 | +- **Unified API**: Standardized interface across different model providers |
| 12 | +- **Simple Model Selection**: Specify models using `provider/model-id` format |
| 13 | + |
| 14 | +Learn more about Poe's API in the [Poe Documentation](https://creator.poe.com/docs/accessing-other-bots-on-poe). |
| 15 | + |
| 16 | +## Setup |
| 17 | + |
| 18 | +The Poe provider is available in the `ai-sdk-provider-poe` module. You can install it with: |
| 19 | + |
| 20 | +<Tabs items={['pnpm', 'npm', 'yarn', 'bun']}> |
| 21 | + <Tab> |
| 22 | + <Snippet text="pnpm add ai-sdk-provider-poe" dark /> |
| 23 | + </Tab> |
| 24 | + <Tab> |
| 25 | + <Snippet text="npm install ai-sdk-provider-poe" dark /> |
| 26 | + </Tab> |
| 27 | + <Tab> |
| 28 | + <Snippet text="yarn add ai-sdk-provider-poe" dark /> |
| 29 | + </Tab> |
| 30 | + <Tab> |
| 31 | + <Snippet text="bun add ai-sdk-provider-poe" dark /> |
| 32 | + </Tab> |
| 33 | +</Tabs> |
| 34 | + |
| 35 | +## Provider Instance |
| 36 | + |
| 37 | +To create a Poe provider instance, use the `createPoe` function: |
| 38 | + |
| 39 | +```typescript |
| 40 | +import { createPoe } from 'ai-sdk-provider-poe'; |
| 41 | + |
| 42 | +const poe = createPoe({ |
| 43 | + apiKey: 'YOUR_POE_API_KEY', |
| 44 | +}); |
| 45 | +``` |
| 46 | + |
| 47 | +You can also use the default `poe` export, which reads from the `POE_API_KEY` environment variable: |
| 48 | + |
| 49 | +```typescript |
| 50 | +import { poe } from 'ai-sdk-provider-poe'; |
| 51 | +``` |
| 52 | + |
| 53 | +## Language Models |
| 54 | + |
| 55 | +Models are specified using a `provider/model-id` format. The provider routes requests to the appropriate API endpoint based on the prefix: |
| 56 | + |
| 57 | +| Prefix | Provider | Endpoint | |
| 58 | +| --- | --- | --- | |
| 59 | +| `anthropic/*` | Anthropic | `/messages` | |
| 60 | +| `openai/*` | OpenAI | `/responses` | |
| 61 | +| `*/*` | Default | `/chat/completions` | |
| 62 | + |
| 63 | +```typescript |
| 64 | +// Anthropic models |
| 65 | +const claude = poe('anthropic/claude-sonnet-4-20250514'); |
| 66 | + |
| 67 | +// OpenAI models |
| 68 | +const gpt = poe('openai/gpt-4o'); |
| 69 | + |
| 70 | +// Google models (via OpenAI-compatible endpoint) |
| 71 | +const gemini = poe('google/gemini-2.0-flash'); |
| 72 | +``` |
| 73 | + |
| 74 | +## Examples |
| 75 | + |
| 76 | +### `generateText` |
| 77 | + |
| 78 | +```typescript |
| 79 | +import { poe } from 'ai-sdk-provider-poe'; |
| 80 | +import { generateText } from 'ai'; |
| 81 | + |
| 82 | +const { text } = await generateText({ |
| 83 | + model: poe('anthropic/claude-sonnet-4-20250514'), |
| 84 | + prompt: 'What is Poe?', |
| 85 | +}); |
| 86 | + |
| 87 | +console.log(text); |
| 88 | +``` |
| 89 | + |
| 90 | +### `streamText` |
| 91 | + |
| 92 | +```typescript |
| 93 | +import { poe } from 'ai-sdk-provider-poe'; |
| 94 | +import { streamText } from 'ai'; |
| 95 | + |
| 96 | +const result = streamText({ |
| 97 | + model: poe('openai/gpt-4o'), |
| 98 | + prompt: 'Write a short story about AI.', |
| 99 | +}); |
| 100 | + |
| 101 | +for await (const chunk of result.textStream) { |
| 102 | + console.log(chunk); |
| 103 | +} |
| 104 | +``` |
| 105 | + |
| 106 | +## Additional Resources |
| 107 | + |
| 108 | +- [Poe Provider Repository](https://github.com/poe-platform/ai-sdk-provider-poe) |
| 109 | +- [Poe API](https://poe.com/api) |
| 110 | +- [Poe API Documentation](https://creator.poe.com/docs/external-applications/external-application-guide) |
0 commit comments