> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/cheahjs/free-llm-api-resources/llms.txt
> Use this file to discover all available pages before exploring further.

# Mistral Codestral

> Free access to Mistral's specialized code generation model

<Note>
  Codestral is Mistral's specialized model for code generation, currently available for free.
</Note>

## Overview

Mistral Codestral is a specialized language model designed specifically for code generation and completion tasks. It's currently available for free through a monthly subscription model.

## Requirements

<Warning>
  **Phone Number Verification Required**: You must verify your phone number to access Codestral.
</Warning>

## Rate Limits

| Limit Type          | Free Tier |
| ------------------- | --------- |
| Requests per minute | 30        |
| Requests per day    | 2,000     |

<Info>
  Codestral is currently free to use on a monthly subscription basis.
</Info>

## Available Models

* **Codestral** - Specialized for code generation, completion, and understanding

## API Usage

<CodeGroup>
  ```python Python theme={null}
  from mistralai import Mistral

  client = Mistral(api_key="YOUR_CODESTRAL_API_KEY")

  response = client.chat.complete(
      model="codestral-latest",
      messages=[
          {
              "role": "user",
              "content": "Write a Python function to calculate fibonacci numbers"
          }
      ]
  )

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

  ```javascript JavaScript theme={null}
  import { Mistral } from '@mistralai/mistralai';

  const client = new Mistral({
      apiKey: process.env.CODESTRAL_API_KEY
  });

  const response = await client.chat.complete({
      model: 'codestral-latest',
      messages: [
          {
              role: 'user',
              content: 'Write a Python function to calculate fibonacci numbers'
          }
      ]
  });

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

  ```bash cURL theme={null}
  curl https://codestral.mistral.ai/v1/chat/completions \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer YOUR_CODESTRAL_API_KEY" \
    -d '{
      "model": "codestral-latest",
      "messages": [
        {
          "role": "user",
          "content": "Write a Python function to calculate fibonacci numbers"
        }
      ]
    }'
  ```
</CodeGroup>

## Getting Started

<Steps>
  <Step title="Create Account">
    Sign up at [codestral.mistral.ai](https://codestral.mistral.ai/)
  </Step>

  <Step title="Verify Phone Number">
    Complete phone number verification
  </Step>

  <Step title="Subscribe to Free Plan">
    Activate the free monthly subscription
  </Step>

  <Step title="Generate API Key">
    Create an API key from your dashboard
  </Step>

  <Step title="Start Coding">
    Use the API for code generation tasks
  </Step>
</Steps>

## Use Cases

<CardGroup cols={2}>
  <Card title="Code Generation" icon="code">
    Generate complete functions and code snippets
  </Card>

  <Card title="Code Completion" icon="wand-magic-sparkles">
    Autocomplete code in your development workflow
  </Card>

  <Card title="Code Explanation" icon="book-open">
    Understand and document existing code
  </Card>

  <Card title="Bug Fixing" icon="bug">
    Identify and fix issues in your code
  </Card>
</CardGroup>

## Key Features

<Info>
  * Specialized for code generation and understanding
  * Supports multiple programming languages
  * Optimized for software development workflows
  * Currently free with generous rate limits
</Info>

## Additional Resources

<CardGroup cols={2}>
  <Card title="Codestral Platform" icon="browser" href="https://codestral.mistral.ai/">
    Access the platform
  </Card>

  <Card title="Mistral Documentation" icon="book" href="https://docs.mistral.ai/">
    API documentation
  </Card>
</CardGroup>
