LlamaIndex provides a powerful framework for building LLM applications with data. You can seamlessly integrate Keywords AI with LlamaIndex’s OpenAI LLM with minimal code changes.
from llama_index.llms.openai import OpenAIllm = OpenAI( api_base="https://api.keywordsai.co/api/", api_key="<Your Keywords AI API Key>", model="gpt-3.5-turbo")
Keywords AI parameters can be passed using extra_body for better handling and customization.
Copy
response = llm.complete( "Tell me a story", extra_body={ "customer_identifier": "user_123", # Track specific users "fallback_models": ["gpt-3.5-turbo"], # Automatic fallbacks "metadata": {"session_id": "abc123"}, # Custom metadata "thread_identifier": "conversation_456", # Group related messages "group_identifier": "team_alpha", # Organize by groups })