Quickstart
A quick example to get you started with the Credo AI SDK.
Setup
- Python
- TypeScript
pip install pycredoai
npm install @credo-ai/sdk
Set your environment variables:
export CREDOAI_API_KEY="your-api-key"
export CREDOAI_TENANT="your-tenant"
Hello World
- Python
- TypeScript
from credoai import CredoAI, UseCaseCreate
# Initialize the client
client = CredoAI()
# Verify connection
ping = client.system.ping()
print(f"Connected: {ping.message}")
# Create a use case
use_case = client.use_cases.create(
data=UseCaseCreate(
name="My First Use Case",
description="Created via the SDK"
)
)
print(f"Created: {use_case.name} (ID: {use_case.id})")
# List all use cases
for uc in client.use_cases.list_all():
print(f" - {uc.name}")
# Clean up
client.use_cases.delete(use_case_id=use_case.id)
print("Deleted use case")
import { createCredoAIClient } from '@credo-ai/sdk';
// Initialize the client
const client = createCredoAIClient('your-tenant');
// Verify connection
const ping = await client.system.ping();
if (ping.error) {
console.error('Connection failed:', ping.error.status);
process.exit(1);
}
console.log('Connected:', ping.data.status);
// Create a use case
const { data: useCase, error } = await client.useCases.create({
name: 'My First Use Case',
description: 'Created via the SDK',
});
if (error) throw error;
console.log(`Created: ${useCase.name} (ID: ${useCase.id})`);
// List all use cases
const { data: list } = await client.useCases.list();
if (list) {
for (const uc of list.items) {
console.log(` - ${uc.name}`);
}
}
// Clean up
await client.useCases.delete(useCase.id);
console.log('Deleted use case');
What's Next?
Now that you have the basics working:
- Learn about Use Cases, Models, and Vendors
- Understand Relationships between resources
- Master Pagination for large datasets
- Handle Errors gracefully
- Use Async Operations for better performance