# 🚀 Guide de DĂ©marrage Rapide ## Installation en 5 minutes ### 1. PrĂ©requis - Python 3.12+ - ClĂ©s API OpenAI et Mistral AI ### 2. Installation ```bash # CrĂ©er environnement virtuel python -m venv venv source venv/bin/activate # Linux/Mac # ou venv\Scripts\activate sur Windows # Installer dĂ©pendances pip install -r requirements.txt ``` ### 3. Configuration Copiez `.env.example` vers `.env` et remplissez vos clĂ©s API: ```env OPENAI_API_KEY=sk-votre-cle-openai MISTRALAI_API_KEY=votre-cle-mistral JWT_SECRET_KEY=changez-moi-en-production ``` ### 4. Lancement ```bash python app.py ``` L'API sera accessible sur: http://localhost:7860 Documentation interactive: http://localhost:7860/docs ## 🎯 Premier test ### 1. Obtenir un token JWT ```bash curl -X POST http://localhost:7860/auth/token ``` Vous obtiendrez: ```json { "access_token": "eyJhbG...", "token_type": "bearer", "expires_in": 3600 } ``` ### 2. Tester la completion ```bash TOKEN="" curl -X POST http://localhost:7860/completion \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "message": "Dis bonjour en français", "model": "gpt-4o", "stream": false }' ``` ### 3. Tester le streaming ```bash curl -N -X POST http://localhost:7860/completion \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "message": "Compte de 1 Ă  10", "model": "gpt-3.5-turbo", "stream": true }' ``` ### 4. Lister les modĂšles disponibles ```bash curl -X GET http://localhost:7860/models \ -H "Authorization: Bearer $TOKEN" ``` ### 5. Transcription audio ```bash curl -X POST http://localhost:7860/transcription \ -H "Authorization: Bearer $TOKEN" \ -F "file=@votre-fichier.mp3" ``` ## 🔧 Configuration avancĂ©e ### LangSmith (monitoring) Activez LangSmith dans `.env`: ```env LANGCHAIN_TRACING_V2=true LANGCHAIN_API_KEY=votre-cle-langsmith LANGCHAIN_PROJECT=routeur-ia ``` ### Production ```bash # GĂ©nĂ©rer un secret JWT sĂ©curisĂ© python -c "import secrets; print(secrets.token_urlsafe(32))" # Lancer en production uvicorn app:app --host 0.0.0.0 --port 7860 --workers 4 ``` ## 🐳 Docker ```bash # Build docker build -t routeur-ia-api . # Run docker run -p 7860:7860 --env-file .env routeur-ia-api ``` ## 📚 Prochaines Ă©tapes - Consultez le [README.md](README.md) pour la documentation complĂšte - Explorez la documentation interactive sur `/docs` - Ajoutez vos propres graphes LangGraph dans `graphs/` - Personnalisez les agents dans `services/agent_registry.py` ## ❓ ProblĂšmes courants ### Erreur "Could not validate credentials" → VĂ©rifiez que vous incluez le token dans le header `Authorization: Bearer ` ### Erreur "API key not found" → VĂ©rifiez votre fichier `.env` et que les clĂ©s API sont correctes ### Erreur au lancement → VĂ©rifiez que toutes les dĂ©pendances sont installĂ©es: `pip install -r requirements.txt` ## 💡 Exemples de code ### Python ```python import requests # Obtenir token token_response = requests.post("http://localhost:7860/auth/token") token = token_response.json()["access_token"] # Completion headers = {"Authorization": f"Bearer {token}"} response = requests.post( "http://localhost:7860/completion", headers=headers, json={ "message": "Bonjour!", "model": "gpt-4o", "stream": False } ) print(response.json()) ``` ### JavaScript ```javascript // Obtenir token const tokenRes = await fetch('http://localhost:7860/auth/token', { method: 'POST' }); const { access_token } = await tokenRes.json(); // Completion const response = await fetch('http://localhost:7860/completion', { method: 'POST', headers: { 'Authorization': `Bearer ${access_token}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ message: 'Hello!', model: 'gpt-4o', stream: false }) }); const data = await response.json(); console.log(data); ``` Bon codage! 🎉