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

# Quickstart

> Get started with TokenFlux in 60 seconds

# Quickstart Guide

Get up and running with TokenFlux in just a few minutes. This guide will help you make your first API call and understand the basics of our platform.

<Info>
  TokenFlux is fully compatible with OpenAI's client libraries. If you have existing OpenAI code, you can switch to TokenFlux by simply changing the base URL and API key.
</Info>

## Prerequisites

Before you begin, you'll need:

* A TokenFlux account ([sign up free](https://tokenflux.ai))
* Credits in your account (purchase after signing up)
* Your API key from the dashboard

## Installation

TokenFlux works with any OpenAI-compatible client library. Choose your preferred language:

<Tabs>
  <Tab title="JavaScript/TypeScript">
    ```bash theme={null}
    npm install openai
    # or
    yarn add openai
    # or
    bun add openai
    ```
  </Tab>

  <Tab title="Python">
    ```bash theme={null}
    pip install openai
    ```
  </Tab>

  <Tab title="cURL">
    No installation needed - cURL is typically pre-installed on most systems.
  </Tab>
</Tabs>

## Your First API Call

Here's how to make your first chat completion request:

<Tabs>
  <Tab title="JavaScript">
    ```javascript theme={null}
    import OpenAI from 'openai';

    const client = new OpenAI({
      apiKey: 'YOUR_TOKENFLUX_API_KEY',
      baseURL: 'https://tokenflux.ai/v1',
    });

    async function main() {
      const completion = await client.chat.completions.create({
        model: 'gpt-4o',
        messages: [
          { role: 'user', content: 'Hello, TokenFlux!' }
        ],
      });

      console.log(completion.choices[0].message.content);
    }

    main();
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    from openai import OpenAI

    client = OpenAI(
        api_key="YOUR_TOKENFLUX_API_KEY",
        base_url="https://tokenflux.ai/v1"
    )

    completion = client.chat.completions.create(
        model="gpt-4o",
        messages=[
            {"role": "user", "content": "Hello, TokenFlux!"}
        ]
    )

    print(completion.choices[0].message.content)
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl https://tokenflux.ai/v1/chat/completions \
      -H "Content-Type: application/json" \
      -H "X-Api-Key: YOUR_TOKENFLUX_API_KEY" \
      -d '{
        "model": "gpt-4o",
        "messages": [
          {"role": "user", "content": "Hello, TokenFlux!"}
        ]
      }'
    ```
  </Tab>
</Tabs>

<Tip>
  Replace `YOUR_TOKENFLUX_API_KEY` with your actual API key from the dashboard. You can find it under Settings → API Keys.
</Tip>

## Try Different Models

TokenFlux provides access to 200+ models from leading providers. Simply change the `model` parameter:

```javascript theme={null}
// Try different models
const models = [
  'gpt-4o',              // OpenAI GPT-4
  'claude-3.5-sonnet',   // Anthropic Claude
  'gemini-pro',          // Google Gemini
  'mistral-large',       // Mistral AI
  'deepseek-chat',       // DeepSeek
];

for (const model of models) {
  const completion = await client.chat.completions.create({
    model: model,
    messages: [{ role: 'user', content: 'What makes you unique?' }],
  });
  
  console.log(`${model}: ${completion.choices[0].message.content}`);
}
```

<Info>
  Use the [Models API](/api-reference/models) to discover all available models with their pricing and capabilities.
</Info>

## Streaming Responses

For a better user experience with long responses, enable streaming:

```javascript theme={null}
const stream = await client.chat.completions.create({
  model: 'gpt-4o',
  messages: [{ role: 'user', content: 'Write a short story' }],
  stream: true,
});

for await (const chunk of stream) {
  const content = chunk.choices[0]?.delta?.content || '';
  process.stdout.write(content);
}
```

## Generate Embeddings

Create vector embeddings for semantic search and RAG applications:

```javascript theme={null}
const embedding = await client.embeddings.create({
  model: 'text-embedding-3-small',
  input: 'TokenFlux makes AI integration simple',
});

console.log(`Embedding dimensions: ${embedding.data[0].embedding.length}`);
```

## Create Images

Generate images from text descriptions:

```javascript theme={null}
// Note: Image generation has a different response format
const response = await fetch('https://tokenflux.ai/v1/images/generations', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-Api-Key': 'YOUR_TOKENFLUX_API_KEY',
  },
  body: JSON.stringify({
    model: 'flux-pro',
    prompt: 'A futuristic city with flying cars at sunset',
    width: 1024,
    height: 1024,
  }),
});

const generation = await response.json();
console.log(`Generation ID: ${generation.id}`);
// Poll for completion or check status
```

## What's Next?

Now that you've made your first API calls, explore these resources:

<CardGroup cols={2}>
  <Card title="Introduction" icon="book" href="/introduction">
    Learn about TokenFlux features and capabilities
  </Card>

  <Card title="Chat Completions" icon="messages" href="/api-reference/chat-completions">
    Master conversational AI with advanced features
  </Card>

  <Card title="Embeddings" icon="vector-square" href="/api-reference/embeddings">
    Build semantic search and RAG applications
  </Card>

  <Card title="Image Generation" icon="image" href="/api-reference/images">
    Create stunning AI-generated images
  </Card>
</CardGroup>

## Quick Links

* **Dashboard**: [tokenflux.ai/dashboard](https://tokenflux.ai/dashboard) - Manage API keys and credits
* **Models & Pricing**: [tokenflux.ai/models](https://tokenflux.ai/models) - Browse available models
* **Status Page**: [status.tokenflux.ai](https://status.tokenflux.ai) - Check system health
* **Support**: [support@tokenflux.ai](mailto:support@tokenflux.ai) - Get help when you need it

<Warning>
  Remember to keep your API key secure and never commit it to version control. Use environment variables or secure key management services in production.
</Warning>
