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¶
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:
Style 1: Pydantic Model (Recommended - Type Safe)¶
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)¶
Style 3: Legacy Parameters (Backward Compatible)¶
Authentication¶
Once you have your API key (see "Getting an API Key" above), you can use it in one of the following ways:
-
Pass it directly to the client:
-
Set environment variable:
import os
client = CosmicMindClient(
api_key=os.getenv("COSMICMIND_API_KEY"),
base_url="https://cosmicmind.pansynapse.com/api"
)
Next Steps¶
- Check out Chat Examples for more detailed usage
- Learn about Avatar System for custom AI personalities
- Read the API Reference for complete documentation
- Follow Best Practices for optimal usage