Skip to content

Quick Start Guide

Get started with CosmicMind Python SDK in minutes.

Prerequisites

  • Python 3.8 or higher
  • A CosmicMind API key (see "Getting an API Key" below)

Getting an API Key

To get started with CosmicMind, you need to request an API key by submitting a signup request.

Submit a Signup Request

Make a POST request to the signup endpoint with your contact information:

import requests

signup_data = {
    "contact_email": "your-email@example.com",
    "contact_name": "Your Name",
    "requested_services": ["cosmicmind"],  # Optional: list of services you're interested in
    "contact_phone": "+1234567890",  # Optional
    "organization_name": "Your Company",  # Optional
    "intended_use_case": "Building an AI assistant"  # Optional
}

response = requests.post(
    "https://cosmicmind.pansynapse.com/api/signup-requests",
    json=signup_data
)

if response.status_code == 200:
    print("Signup request submitted successfully!")
    print("You will receive your API key via email.")
else:
    print(f"Error: {response.status_code}")
    print(response.text)

Required Fields: - contact_email: Your email address (must be a valid email format) - contact_name: Your full name

Optional Fields: - requested_services: List of services you're interested in (e.g., ["cosmicmind"]) - contact_phone: Your phone number - organization_name: Your company or organization name - intended_use_case: Brief description of how you plan to use CosmicMind

After submitting your signup request, you'll receive your API key via email. Once you have your API key, you can proceed with the installation and usage steps below.

Installation

pip install cosmicmind

Basic Usage

1. Initialize the Client

from cosmicmind import CosmicMindClient

client = CosmicMindClient(
    api_key="sk-your-api-key-here",
    base_url="https://cosmicmind.pansynapse.com/api",  # Must include /api
    api_version="v1"  # API version (defaults to v1) - sent in X-API-Version header
)

Note: API versioning is handled via the X-API-Version HTTP header, not in request payloads. The api_version parameter sets this header for all requests made by the client.

2. Send Your First Message

# Send a chat message - context is automatically managed
response = client.chat.send(
    message="My name is Alice and I love hiking",
    user_id="alice_123"
)
print(response.message)

3. Continue the Conversation

CosmicMind remembers previous context:

# Later conversation - CosmicMind remembers!
response = client.chat.send(
    message="What outdoor activities do I enjoy?",
    user_id="alice_123"
)
print(response.message)  # Will reference hiking preference

Three Ways to Send Requests

The SDK supports multiple input styles:

from cosmicmind.models import ChatRequest

request = ChatRequest(
    messages=["Hello!"],
    user_id="alice",
    llm="cerebras",
    llm_model="llama-3.3-70b"
)
response = client.chat.send(request)

Style 2: Dictionary (Validates Internally)

response = client.chat.send({
    "messages": ["Hello!"],
    "user_id": "alice",
    "llm": "cerebras"
})

Style 3: Legacy Parameters (Backward Compatible)

response = client.chat.send(
    message="Hello!",
    user_id="alice",
    llm="cerebras"
)

Authentication

Once you have your API key (see "Getting an API Key" above), you can use it in one of the following ways:

  1. Pass it directly to the client:

    client = CosmicMindClient(
        api_key="sk-your-key",
        base_url="https://cosmicmind.pansynapse.com/api"
    )
    

  2. Set environment variable:

    export COSMICMIND_API_KEY="sk-your-key"
    

import os
client = CosmicMindClient(
    api_key=os.getenv("COSMICMIND_API_KEY"),
    base_url="https://cosmicmind.pansynapse.com/api"
)

Next Steps