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

# Next Steps

> You've made your first AI request! Here's what to explore next.

## Learn Advanced Features

> [card] [Streaming Responses](https://docs.megallm.io/en/api-reference/endpoint/streaming.md)
>
> Get real-time responses as they're generated

> [card] [Function Calling](https://docs.megallm.io/en/api-reference/endpoint/function-calling.md)
>
> Let AI interact with external tools and APIs

> [card] [Vision Support](https://docs.megallm.io/en/dev-docs/openai/chat-completions.md)
>
> Process images with multimodal models

> [card] [API Documentation](https://docs.megallm.io/en/api-reference/introduction.md)
>
> Complete API reference and guides

## Explore Documentation

> [card] [API Reference](https://docs.megallm.io/en/api-reference/introduction.md)
>
> Complete API documentation

> [card] [OpenAI API](https://docs.megallm.io/en/dev-docs/openai/overview.md)
>
> OpenAI-compatible endpoints

> [card] [Anthropic API](https://docs.megallm.io/en/dev-docs/anthropic/overview.md)
>
> Anthropic Claude-compatible endpoints

> [card] [Models Catalog](https://docs.megallm.io/en/home/models.md)
>
> Browse all 70+ available models

## Build Real Applications

### 1. Chatbot

Build an intelligent chatbot:

```python theme={null}
from openai import OpenAI

client = OpenAI(
    base_url="https://ai.megallm.io/v1",
    api_key="your-key"
)

def chatbot(user_message, history=[]):
    history.append({"role": "user", "content": user_message})

    response = client.chat.completions.create(
        model="gpt-4",
        messages=history
    )

    assistant_message = response.choices[0].message.content
    history.append({"role": "assistant", "content": assistant_message})

    return assistant_message, history
```

### 2. Content Generator

Generate blog posts, emails, or social media content:

```python theme={null}
def generate_content(topic, content_type="blog"):
    prompts = {
        "blog": f"Write a comprehensive blog post about {topic}",
        "email": f"Write a professional email about {topic}",
        "tweet": f"Write an engaging tweet about {topic}"
    }

    response = client.chat.completions.create(
        model="claude-3.5-sonnet",
        messages=[{"role": "user", "content": prompts[content_type]}],
        temperature=0.7
    )

    return response.choices[0].message.content
```

### 3. Code Assistant

Build a coding helper:

```python theme={null}
def code_assistant(task, language="python"):
    prompt = f"Write {language} code to {task}. Include comments and error handling."

    response = client.chat.completions.create(
        model="gpt-4",
        messages=[{"role": "user", "content": prompt}],
        temperature=0.2  # Lower temperature for more deterministic code
    )

    return response.choices[0].message.content
```

### 4. Data Analyzer

Analyze data and generate insights:

```python theme={null}
def analyze_data(data_description):
    prompt = f"""
    Analyze this data and provide insights:
    {data_description}

    Provide:
    1. Key findings
    2. Trends
    3. Recommendations
    """

    response = client.chat.completions.create(
        model="claude-opus-4-1-20250805",  # Best for analysis
        messages=[{"role": "user", "content": prompt}]
    )

    return response.choices[0].message.content
```

## Best Practices

> [accordion] Choose the Right Model
>
> * **GPT-4**: Best for complex reasoning
> * **GPT-3.5 Turbo**: Fast and cost-effective
> * **Claude Opus**: Excellent for analysis and long context
> * **Claude Sonnet**: Balanced performance
> * **Gemini Pro**: Strong multimodal capabilities
>
> See [Models Catalog](https://docs.megallm.io/home/models) for detailed comparisons.

> [accordion] Optimize Costs
>
> * Start with cheaper models for testing
> * Use `max_tokens` to limit response length
> * Cache responses when possible
> * Use streaming to improve perceived performance
> * Monitor usage in your dashboard

> [accordion] Handle Errors Gracefully
>
> ```python theme={null}
> from openai import OpenAI, AuthenticationError, RateLimitError
> import time
>
> def make_request_with_retry(messages, max_retries=3):
>     for attempt in range(max_retries):
>         try:
>             return client.chat.completions.create(
>                 model="gpt-4",
>                 messages=messages
>             )
>         except RateLimitError:
>             if attempt < max_retries - 1:
>                 time.sleep(2 ** attempt)  # Exponential backoff
>             else:
>                 raise
>         except AuthenticationError:
>             print("Invalid API key")
>             raise
> ```

> [accordion] Optimize Prompts
>
> * Be specific and clear
> * Provide examples when needed
> * Use system messages to set context
> * Break complex tasks into steps
> * Test different temperature settings

> [accordion] Manage Context
>
> * Keep track of conversation history
> * Limit history to avoid token limits
> * Summarize old messages if needed
> * Use prompt caching for repeated content

## Production Considerations

### Security

* Store API keys in environment variables
* Never commit keys to version control
* Use different keys for dev/staging/production
* Rotate keys regularly
* Monitor usage for anomalies

### Performance

* Use streaming for better UX
* Implement caching where appropriate
* Add retry logic with exponential backoff
* Monitor response times
* Consider using webhooks for async operations

### Monitoring

* Track token usage
* Monitor error rates
* Log API requests (without sensitive data)
* Set up alerts for quota limits
* Review costs regularly

### Scaling

* Implement rate limiting
* Use queues for high-volume requests
* Cache common responses
* Consider batching requests
* Plan for failover strategies

## Join the Community

> [card] [Discord](https://discord.gg/Megallm)
>
> Chat with other developers

> [card] [GitHub](https://github.com/megallm)
>
> View examples and contribute

> [card] [Twitter/X](https://x.com/megallmio)
>
> Follow for updates

> [card] [YouTube](https://youtube.com/@Megallmio)
>
> Watch tutorials

## Get Help

> [accordion] Check the FAQ
>
> Most common questions are answered in our [FAQ](https://docs.megallm.io/home/faq.md).

> [accordion] Read the Docs
>
> Comprehensive guides available in [Developer Docs](https://docs.megallm.io/dev-docs/overview).

> [accordion] Contact Support
>
> Email us at [support@megallm.io](mailto:support@megallm.io) for technical assistance.

> [accordion] Report Issues
>
> Found a bug? Report it on [GitHub](https://github.com/megallm).

## Useful Resources

* **[API Reference](https://docs.megallm.io/api-reference/introduction)** - Complete API documentation
* **[Models Catalog](https://docs.megallm.io/home/models)** - All 70+ models with pricing
* **[CLI Tool](https://docs.megallm.io/cli/overview)** - Set up AI coding assistants
* **[FAQ](https://docs.megallm.io/home/faq.md)** - Common questions and answers
* **[Changelog](https://docs.megallm.io/releases/overview)** - Latest updates

## Ready to Build?

Start building your AI application today. If you need help, we're here for you!

> [card] [API Reference](https://docs.megallm.io/en/api-reference/introduction.md)
>
> Complete documentation

> [card] [Support](mailto:support@megallm.io)
>
> Get help from our team


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.