Skip to main content

Get started with Mielto API

Build AI applications with unlimited context and intelligent memory management in minutes.

Step 1: Authentication

Create your Mielto account to get started: Sign up
After registration, create an API key for your applications:
  1. Login to get your access token
  2. Create an API key via the API Keys dashboard
  3. Use this key in your application headers
Store your API key securely - it provides full access to your workspace!

Step 2: Create your first collection

Set up a collection for your knowledge base:
curl -X POST https://api.mielto.com/api/v1/collections \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Company Knowledge",
    "description": "Internal company information and procedures"
  }'
Quickly call this endpoint from clients:
// TypeScript/JavaScript
async function createCollection() {
  const response = await fetch('https://api.mielto.com/api/v1/collections', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.MIELTO_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      name: 'Company Knowledge',
      description: 'Internal company information and procedures',
    }),
  });
  if (!response.ok) throw new Error(`Request failed: ${response.status}`);
  return await response.json();
}
# Python
import os, requests

def create_collection():
    res = requests.post(
        'https://api.mielto.com/api/v1/collections',
        headers={
            'Authorization': f"Bearer {os.environ.get('MIELTO_API_KEY')}",
            'Content-Type': 'application/json',
        },
        json={
            'name': 'Company Knowledge',
            'description': 'Internal company information and procedures',
        },
        timeout=30,
    )
    res.raise_for_status()
    return res.json()

Step 3: Create your first memory

Create a memory to store important context:
curl -X POST https://api.mielto.com/api/v1/memories \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "user_id": "your-user-id",
    "memory": "I prefer concise responses and work in software development",
    "topics": ["preferences", "work"]
  }'

Step 4: Start a conversation with context

Now use Mielto’s OpenAI-compatible endpoint with automatic context injection:
curl -X POST https://api.mielto.com/api/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "x-user-id: your-user-id" \
  -d '{
    "model": "gpt-4",
    "messages": [
      {"role": "user", "content": "Help me write a function"}
    ]
  }'
SDK examples (set base URL, API key, and headers):
# Python (openai>=1.0.0)
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.mielto.com/api/v1",
    default_headers={
        "x-user-id": "your-user-id",
    },
)

resp = client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "Help me write a function"}],
)
print(resp.choices[0].message.content)
// TypeScript/JavaScript (openai@^4)
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.MIELTO_API_KEY!,
  baseURL: 'https://api.mielto.com/api/v1',
  defaultHeaders: {
    'x-user-id': 'your-user-id',
  },
});

const resp = await client.chat.completions.create({
  model: 'gpt-4',
  messages: [{ role: 'user', content: 'Help me write a function' }],
});
console.log(resp.choices[0].message?.content);
Mielto automatically injects relevant memories and knowledge!

Next steps

Now that you’ve created your first memory and collection, explore these powerful features:
Need help? Check our complete API reference for detailed endpoint documentation.