--- title: Code Examples description: Practical examples for building on AITBC --- # Code Examples This section provides practical examples for common tasks on the AITBC platform. ## Python Examples ### Basic Job Submission ```python from aitbc import AITBCClient client = AITBCClient(api_key="your_key") job = client.jobs.create({ "name": "image-classification", "type": "ai-inference", "model": { "type": "python", "entrypoint": "model.py", "requirements": ["torch", "pillow"] } }) result = client.jobs.wait_for_completion(job["job_id"]) ``` ### Batch Job Processing ```python import asyncio from aitbc import AsyncAITBCClient async def process_images(image_paths): client = AsyncAITBCClient(api_key="your_key") tasks = [] for path in image_paths: job = await client.jobs.create({ "name": f"process-{path}", "type": "image-analysis" }) tasks.append(client.jobs.wait_for_completion(job["job_id"])) results = await asyncio.gather(*tasks) return results ``` ## JavaScript Examples ### React Component ```jsx import React, { useState, useEffect } from 'react'; import { AITBCClient } from '@aitbc/client'; function JobList() { const [jobs, setJobs] = useState([]); const client = new AITBCClient({ apiKey: 'your_key' }); useEffect(() => { async function fetchJobs() { const jobList = await client.jobs.list(); setJobs(jobList); } fetchJobs(); }, []); return (
Status: {job.status}