> ## Documentation Index
> Fetch the complete documentation index at: https://docs.core-ai.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Installation

> Install core-ai with your preferred package manager

# Installation

core-ai is distributed as npm packages. Install the core package along with your preferred provider adapter.

## Requirements

* Node.js 22 or higher
* Zod 4 (`zod@^4.0.0`)
* TypeScript 5.7+ (recommended)

## Install the core package

<CodeGroup>
  ```bash npm theme={null}
  npm install @core-ai/core-ai
  ```

  ```bash yarn theme={null}
  yarn add @core-ai/core-ai
  ```

  ```bash pnpm theme={null}
  pnpm add @core-ai/core-ai
  ```
</CodeGroup>

## Install a provider adapter

You need at least one provider adapter to use core-ai. Install the package for your preferred LLM provider:

<Tabs>
  <Tab title="OpenAI">
    <CodeGroup>
      ```bash npm theme={null}
      npm install @core-ai/openai
      ```

      ```bash yarn theme={null}
      yarn add @core-ai/openai
      ```

      ```bash pnpm theme={null}
      pnpm add @core-ai/openai
      ```
    </CodeGroup>

    <Note>
      The OpenAI adapter supports chat completion, streaming, structured outputs, embeddings, and image generation.
    </Note>
  </Tab>

  <Tab title="Anthropic">
    <CodeGroup>
      ```bash npm theme={null}
      npm install @core-ai/anthropic
      ```

      ```bash yarn theme={null}
      yarn add @core-ai/anthropic
      ```

      ```bash pnpm theme={null}
      pnpm add @core-ai/anthropic
      ```
    </CodeGroup>

    <Note>
      The Anthropic adapter supports chat completion, streaming, structured outputs, tool calling, vision, and reasoning with Claude models.
    </Note>
  </Tab>

  <Tab title="Google GenAI">
    <CodeGroup>
      ```bash npm theme={null}
      npm install @core-ai/google-genai
      ```

      ```bash yarn theme={null}
      yarn add @core-ai/google-genai
      ```

      ```bash pnpm theme={null}
      pnpm add @core-ai/google-genai
      ```
    </CodeGroup>

    <Note>
      The Google GenAI adapter supports chat, streaming, structured outputs, embeddings, multimodal input, and image generation.
    </Note>
  </Tab>

  <Tab title="Mistral">
    <CodeGroup>
      ```bash npm theme={null}
      npm install @core-ai/mistral
      ```

      ```bash yarn theme={null}
      yarn add @core-ai/mistral
      ```

      ```bash pnpm theme={null}
      pnpm add @core-ai/mistral
      ```
    </CodeGroup>

    <Note>
      The Mistral adapter supports chat completion, streaming, structured outputs, tool calling, multimodal input, reasoning output, and embeddings.
    </Note>
  </Tab>
</Tabs>

## Add observability (optional)

core-ai provides middleware packages for tracing and monitoring model operations. See the [Observability](/observability/overview) docs for full setup guides.

<Tabs>
  <Tab title="OpenTelemetry">
    <CodeGroup>
      ```bash npm theme={null}
      npm install @core-ai/opentelemetry @opentelemetry/api
      ```

      ```bash yarn theme={null}
      yarn add @core-ai/opentelemetry @opentelemetry/api
      ```

      ```bash pnpm theme={null}
      pnpm add @core-ai/opentelemetry @opentelemetry/api
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Axiom">
    <CodeGroup>
      ```bash npm theme={null}
      npm install @core-ai/axiom @opentelemetry/api @opentelemetry/sdk-node @opentelemetry/exporter-trace-otlp-http
      ```

      ```bash yarn theme={null}
      yarn add @core-ai/axiom @opentelemetry/api @opentelemetry/sdk-node @opentelemetry/exporter-trace-otlp-http
      ```

      ```bash pnpm theme={null}
      pnpm add @core-ai/axiom @opentelemetry/api @opentelemetry/sdk-node @opentelemetry/exporter-trace-otlp-http
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Langfuse">
    <CodeGroup>
      ```bash npm theme={null}
      npm install @core-ai/langfuse @langfuse/otel @langfuse/tracing
      ```

      ```bash yarn theme={null}
      yarn add @core-ai/langfuse @langfuse/otel @langfuse/tracing
      ```

      ```bash pnpm theme={null}
      pnpm add @core-ai/langfuse @langfuse/otel @langfuse/tracing
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## Get API keys

You need an API key from your chosen provider. Set it as an environment variable:

<CodeGroup>
  ```bash OpenAI theme={null}
  export OPENAI_API_KEY="your-api-key-here"
  ```

  ```bash Anthropic theme={null}
  export ANTHROPIC_API_KEY="your-api-key-here"
  ```

  ```bash Google GenAI theme={null}
  export GOOGLE_API_KEY="your-api-key-here"
  ```

  ```bash Mistral theme={null}
  export MISTRAL_API_KEY="your-api-key-here"
  ```
</CodeGroup>

<Tip>
  Use a `.env` file with `dotenv` to manage your environment variables during development:

  ```bash theme={null}
  npm install dotenv
  ```

  Then add `import 'dotenv/config';` at the top of your entry file.
</Tip>

## Verify installation

Create a simple test file to verify your installation:

```typescript test.ts theme={null}
import { generate } from '@core-ai/core-ai';
import { createOpenAI } from '@core-ai/openai';

const openai = createOpenAI({ apiKey: process.env.OPENAI_API_KEY });
const model = openai.chatModel('gpt-5-mini');

const result = await generate({
  model,
  messages: [{ role: 'user', content: 'Hello!' }],
});

console.log(result.content);
```

Run it with:

```bash theme={null}
npx tsx test.ts
```

<Note>
  core-ai uses ES modules (`"type": "module"`). Make sure your `package.json` includes this or use `.mts` file extensions.
</Note>

## Next steps

<CardGroup cols={2}>
  <Card title="Quickstart" icon="bolt" href="/quickstart">
    Build your first chat completion in 2 minutes
  </Card>

  <Card title="Examples" icon="code" href="/examples/overview">
    Explore real-world implementation examples
  </Card>
</CardGroup>
