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

# Quick Start

> Make your first Samurai AI API call in under 5 minutes. No special SDK needed — use the OpenAI library.

## Step 1: Get your API Key

1. Sign up at [samurai-ai.com](https://www.samuraiapi.in)
2. Go to your [Dashboard](https://www.samuraiapi.in/dashboard)
3. Click **API Keys → Create New Key**
4. Copy your key — it starts with `sk-samurai-`

<Warning>
  Store your API key in an environment variable. Never commit it to version control or expose it in client-side code.
</Warning>

## Step 2: Install the SDK

Use the official **OpenAI SDK** — no special Samurai package needed:

<CodeGroup>
  ```bash pip theme={null}
  pip install openai
  ```

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

  ```bash yarn theme={null}
  yarn add openai
  ```
</CodeGroup>

## Step 3: Set your environment variable

```bash theme={null}
export SAMURAI_API_KEY="sk-samurai-YOUR_KEY"
```

Or create a `.env` file:

```bash .env theme={null}
SAMURAI_API_KEY=sk-samurai-YOUR_KEY
```

## Step 4: Make your first request

<CodeGroup>
  ```python Python theme={null}
  import os
  from openai import OpenAI

  client = OpenAI(
      api_key=os.environ.get("SAMURAI_API_KEY"),
      base_url="https://www.samuraiapi.in/v1"  # Only change from OpenAI
  )

  response = client.chat.completions.create(
      model="gpt-4o",
      messages=[
          {"role": "system", "content": "You are a helpful assistant."},
          {"role": "user", "content": "What is bushido?"}
      ]
  )

  print(response.choices[0].message.content)
  # => "Bushido is the code of ethics followed by Japanese samurai warriors..."
  ```

  ```javascript Node.js theme={null}
  import OpenAI from 'openai';

  const client = new OpenAI({
    apiKey: process.env.SAMURAI_API_KEY,
    baseURL: 'https://www.samuraiapi.in/v1'   // Only change from OpenAI
  });

  const response = await client.chat.completions.create({
    model: 'gpt-4o',
    messages: [
      { role: 'system', content: 'You are a helpful assistant.' },
      { role: 'user', content: 'What is bushido?' }
    ]
  });

  console.log(response.choices[0].message.content);
  ```

  ```bash cURL theme={null}
  curl https://www.samuraiapi.in/v1/chat/completions \
    -H "Authorization: Bearer $SAMURAI_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "gpt-4o",
      "messages": [
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What is bushido?"}
      ]
    }'
  ```
</CodeGroup>

You'll get a response like:

```json theme={null}
{
  "choices": [{
    "message": {
      "role": "assistant",
      "content": "Bushido is the ethical code of conduct historically observed by the samurai of Japan..."
    },
    "finish_reason": "stop"
  }],
  "usage": { "prompt_tokens": 24, "completion_tokens": 87, "total_tokens": 111 }
}
```

## Try a cheaper model (same quality)

```python theme={null}
# DeepSeek V3 — $0.007/1M input tokens (vs $1.25 for GPT-4o)
response = client.chat.completions.create(
    model="deepseek-chat",
    messages=[{"role": "user", "content": "What is bushido?"}]
)
print(response.choices[0].message.content)
```

## Try streaming

```python theme={null}
stream = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Tell me a haiku about samurai."}],
    stream=True
)
for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)
```

## What's next?

<CardGroup cols={2}>
  <Card title="Chat Completions" icon="message" href="/api/chat-completions">
    Full parameter reference and multi-turn examples.
  </Card>

  <Card title="Streaming" icon="wave-square" href="/api/streaming">
    Real-time streaming with SSE and Vercel AI SDK.
  </Card>

  <Card title="All Models" icon="microchip" href="/reference/models">
    GPT-4.1, Claude Opus 4, Gemini 2.5 Pro, Llama 3.3 and 400+ more.
  </Card>

  <Card title="API Playground" icon="flask" href="/api-reference/introduction">
    Test every endpoint live in your browser.
  </Card>
</CardGroup>

***

## Step 1: Get your API Key

1. Sign up at [samurai-ai.com](https://www.samuraiapi.in)
2. Go to your [Dashboard](https://www.samuraiapi.in/dashboard)
3. Click **API Keys** → **Create New Key**
4. Copy your key — it starts with `sk-samurai-`

<Warning>
  Never share your API key or commit it to version control. Always use environment variables.
</Warning>

## Step 2: Install the SDK

Samurai AI is 100% OpenAI-compatible. Use the official OpenAI SDK — no special package needed:

<CodeGroup>
  ```bash pip theme={null}
  pip install openai
  ```

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

  ```bash yarn theme={null}
  yarn add openai
  ```
</CodeGroup>

## Step 3: Make your first request

<CodeGroup>
  ```python Python theme={null}
  from openai import OpenAI

  client = OpenAI(
      api_key="sk-samurai-YOUR_KEY",
      base_url="https://api.samuraiapi.in/v1"
  )

  response = client.chat.completions.create(
      model="gpt-4o",
      messages=[{"role": "user", "content": "Hello! What can you do?"}]
  )

  print(response.choices[0].message.content)
  ```

  ```javascript Node.js theme={null}
  import OpenAI from 'openai';

  const client = new OpenAI({
    apiKey: 'sk-samurai-YOUR_KEY',
    baseURL: 'https://api.samuraiapi.in/v1'
  });

  const response = await client.chat.completions.create({
    model: 'gpt-4o',
    messages: [{ role: 'user', content: 'Hello! What can you do?' }]
  });

  console.log(response.choices[0].message.content);
  ```

  ```bash cURL theme={null}
  curl https://api.samuraiapi.in/v1/chat/completions \
    -H "Authorization: Bearer sk-samurai-YOUR_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "gpt-4o",
      "messages": [{"role": "user", "content": "Hello! What can you do?"}]
    }'
  ```
</CodeGroup>

## What's next?

<CardGroup cols={2}>
  <Card title="Chat Completions" icon="message" href="/api/chat-completions">
    Learn all parameters and options for chat.
  </Card>

  <Card title="Browse Models" icon="microchip" href="/reference/models">
    See all 400+ available models.
  </Card>

  <Card title="Image Generation" icon="image" href="/api/images/overview">
    Generate images with DALL-E 3, Flux, and more.
  </Card>

  <Card title="Streaming" icon="wave-square" href="/api/streaming">
    Stream responses in real time.
  </Card>
</CardGroup>
