
# AI/ML API Provider

The [AI/ML API](https://aimlapi.com/?utm_source=aimlapi-vercel-ai&utm_medium=github&utm_campaign=integration) provider gives access to more than 300 AI models over an OpenAI-compatible API.

## Setup

The AI/ML API provider is available via the `@ai-ml.api/aimlapi-vercel-ai` module. You can install it with:

<Tabs items={['pnpm', 'npm', 'yarn', 'bun']}>
  <Tab>
    <Snippet text="pnpm add @ai-ml.api/aimlapi-vercel-ai" dark />
  </Tab>
  <Tab>
    <Snippet text="npm install @ai-ml.api/aimlapi-vercel-ai" dark />
  </Tab>
  <Tab>
    <Snippet text="yarn add @ai-ml.api/aimlapi-vercel-ai" dark />
  </Tab>
  <Tab>
    <Snippet text="bun add @ai-ml.api/aimlapi-vercel-ai" dark />
  </Tab>
</Tabs>

### API Key

Set the `AIMLAPI_API_KEY` environment variable with your key:

```bash
export AIMLAPI_API_KEY="sk-..."
```

## Provider Instance

You can import the default provider instance `aimlapi`:

```ts
import { aimlapi } from '@ai-ml.api/aimlapi-vercel-ai';
```

## Language Models

Create models for text generation with `aimlapi` and use them with `generateText`:

```ts
import { aimlapi } from '@ai-ml.api/aimlapi-vercel-ai';
import { generateText } from 'ai';

const { text } = await generateText({
  model: aimlapi('gpt-4o'),
  system: 'You are a friendly assistant!',
  prompt: 'Why is the sky blue?',
});
```

## Image Generation

You can generate images by calling `doGenerate` on an image model:

```ts
import { aimlapi } from '@ai-ml.api/aimlapi-vercel-ai';

const model = aimlapi.imageModel('flux-pro');

const res = await model.doGenerate({
  prompt: 'a red balloon floating over snowy mountains, cinematic',
  n: 1,
  aspectRatio: '16:9',
  seed: 42,
  size: '1024x768',
  providerOptions: {},
});

console.log(`✅ Generated image url: ${res.images[0]}`);
```

## Embeddings

AI/ML API also supports embedding models:

```ts
import { aimlapi } from '@ai-ml.api/aimlapi-vercel-ai';
import { embed } from 'ai';

const { embedding } = await embed({
  model: aimlapi.embeddingModel('text-embedding-3-large'),
  value: 'sunny day at the beach',
});
```

For more information and a full model list, visit the [AI/ML API dashboard](https://aimlapi.com/app?utm_source=aimlapi-vercel-ai&utm_medium=github&utm_campaign=integration) and the [AI/ML API documentation](https://docs.aimlapi.com/?utm_source=aimlapi-vercel-ai&utm_medium=github&utm_campaign=integration).


## Navigation

- [Writing a Custom Provider](/v7/providers/community-providers/custom-providers)
- [A2A](/v7/providers/community-providers/a2a)
- [ACP (Agent Client Protocol)](/v7/providers/community-providers/acp)
- [Aihubmix](/v7/providers/community-providers/aihubmix)
- [AI/ML API](/v7/providers/community-providers/aimlapi)
- [Anthropic Vertex](/v7/providers/community-providers/anthropic-vertex-ai)
- [Automatic1111](/v7/providers/community-providers/automatic1111)
- [Azure AI](/v7/providers/community-providers/azure-ai)
- [Browser AI](/v7/providers/community-providers/browser-ai)
- [Claude Code](/v7/providers/community-providers/claude-code)
- [Cloudflare AI Gateway](/v7/providers/community-providers/cloudflare-ai-gateway)
- [Cloudflare Workers AI](/v7/providers/community-providers/cloudflare-workers-ai)
- [Codex CLI](/v7/providers/community-providers/codex-cli)
- [Crosshatch](/v7/providers/community-providers/crosshatch)
- [Dify](/v7/providers/community-providers/dify)
- [Firemoon](/v7/providers/community-providers/firemoon)
- [FriendliAI](/v7/providers/community-providers/friendliai)
- [Gemini CLI](/v7/providers/community-providers/gemini-cli)
- [Helicone](/v7/providers/community-providers/helicone)
- [Inflection AI](/v7/providers/community-providers/inflection-ai)
- [Jina AI](/v7/providers/community-providers/jina-ai)
- [LangDB](/v7/providers/community-providers/langdb)
- [Letta](/v7/providers/community-providers/letta)
- [llama.cpp](/v7/providers/community-providers/llama-cpp)
- [LlamaGate](/v7/providers/community-providers/llamagate)
- [MCP Sampling AI Provider](/v7/providers/community-providers/mcp-sampling)
- [Mem0](/v7/providers/community-providers/mem0)
- [MiniMax](/v7/providers/community-providers/minimax)
- [Mixedbread](/v7/providers/community-providers/mixedbread)
- [Ollama](/v7/providers/community-providers/ollama)
- [OpenCode](/v7/providers/community-providers/opencode-sdk)
- [OpenRouter](/v7/providers/community-providers/openrouter)
- [Portkey](/v7/providers/community-providers/portkey)
- [Qwen](/v7/providers/community-providers/qwen)
- [React Native Apple](/v7/providers/community-providers/react-native-apple)
- [Requesty](/v7/providers/community-providers/requesty)
- [Runpod](/v7/providers/community-providers/runpod)
- [SambaNova](/v7/providers/community-providers/sambanova)
- [SAP AI Core](/v7/providers/community-providers/sap-ai)
- [Sarvam](/v7/providers/community-providers/sarvam)
- [Soniox](/v7/providers/community-providers/soniox)
- [Spark](/v7/providers/community-providers/spark)
- [Supermemory](/v7/providers/community-providers/supermemory)
- [Voyage AI](/v7/providers/community-providers/voyage-ai)
- [Zhipu AI (Z.AI)](/v7/providers/community-providers/zhipu)
- [vectorstores](/v7/providers/community-providers/vectorstores)
- [Codex CLI (App Server)](/v7/providers/community-providers/codex-app-server)
- [Apertis](/v7/providers/community-providers/apertis)
- [OLLM](/v7/providers/community-providers/ollm)
- [Cencori](/v7/providers/community-providers/cencori)
- [Hindsight](/v7/providers/community-providers/hindsight)
- [ZeroEntropy](/v7/providers/community-providers/zeroentropy)
- [Flowise](/v7/providers/community-providers/flowise)


[Full Sitemap](/sitemap.md)
