{"id":9292,"library":"sap-ai-sdk-gen","title":"SAP AI SDK for Generative AI","description":"The SAP Cloud SDK for AI (Python) is designed to simplify interactions with generative AI APIs and services, particularly within the SAP ecosystem. It provides unified interfaces for various large language models (LLMs), enabling developers to easily integrate AI capabilities into their applications. The library is currently at version 6.7.0 and maintains a regular release cadence with updates and new features.","status":"active","version":"6.7.0","language":"python","source_language":"en","source_url":"https://github.com/SAP/cloud-sdk-for-ai-python","tags":["SAP","AI","Generative AI","LLM","Cloud"],"install":[{"cmd":"pip install sap-ai-sdk-gen","lang":"bash","label":"Install core SDK"}],"dependencies":[],"imports":[{"wrong":"from sap_ai_sdk.generative_ai import GenerativeAI","symbol":"GenAIHubProxyClient","correct":"from gen_ai_hub import GenAIHubProxyClient"},{"symbol":"proxy","correct":"from gen_ai_hub import proxy"}],"quickstart":{"code":"import os\nfrom sap_ai_sdk.generative_ai import GenerativeAI\nfrom sap_ai_sdk.generative_ai.completion import Completion\n\n# Set your API key as an environment variable (e.g., OPENAI_API_KEY).\n# For SAP AI Core, ensure AI_API_URL, AI_CLIENT_ID, AI_CLIENT_SECRET, AI_AUTH_URL are set.\n# Example: os.environ['OPENAI_API_KEY'] = os.environ.get('OPENAI_API_KEY', '') # For demo, ensure it's loaded.\n\ntry:\n    # Initialize the GenerativeAI client. It automatically detects configured providers.\n    ai_client = GenerativeAI()\n\n    # Get the completion service\n    completion_service: Completion = ai_client.get_completion_service()\n\n    prompt = \"Explain the concept of quantum entanglement in simple terms.\"\n    model_name = \"gpt-3.5-turbo\" # Use a model supported by your configured provider\n\n    print(f\"Requesting completion for model: {model_name}\")\n    response = completion_service.create(\n        prompt=prompt,\n        model_name=model_name,\n        # provider=\"openai\" # Optionally specify if multiple providers are configured\n    )\n\n    print(\"\\nGenerated Text:\")\n    print(response.text)\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Please ensure your environment variables (e.g., OPENAI_API_KEY) are correctly set\")\n    print(\"and that a suitable provider is configured for the chosen model.\")","lang":"python","description":"This quickstart demonstrates how to initialize the `GenerativeAI` client and use its `Completion` service. It relies on environment variables for API key configuration (e.g., `OPENAI_API_KEY`) and attempts to generate text using a specified model."},"warnings":[{"fix":"Initialize `GenerativeAI` and then use methods like `ai_client.get_completion_service()` to obtain service instances.","message":"The SDK underwent significant refactoring in version 6.x. The `GenerativeAI` class is now the central entry point for all services (completion, chat, image generation, etc.). Direct instantiation of services like `Completion()` with a configuration object is no longer the recommended or supported pattern.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Ensure relevant environment variables (e.g., `OPENAI_API_KEY`, `AI_API_URL`, `AI_CLIENT_ID`, `AI_CLIENT_SECRET`) are correctly set before initializing the `GenerativeAI` client. Refer to the documentation for provider-specific requirements.","message":"Authentication for generative AI providers (e.g., OpenAI, Azure OpenAI, SAP AI Core) relies heavily on environment variables or explicit `Credentials` objects. Misconfigured or missing API keys/credentials will lead to authentication errors (e.g., 401 Unauthorized).","severity":"gotcha","affected_versions":"all"},{"fix":"Always check which providers are configured and, if necessary, explicitly pass the `provider` name to the relevant methods.","message":"When using multiple configured providers or if auto-detection fails, explicitly specifying the `provider` parameter when getting a service (e.g., `ai_client.get_completion_service(provider=\"openai\")`) or in the service call (`completion_service.create(..., provider=\"openai\")`) can prevent `ProviderNotFoundException`.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'6.7.0':56 'ai':2,6,12,21,45,69,71 'api':22 'applic':49 'cadenc':62 'capabl':46 'cloud':9,73 'current':53 'design':15 'develop':41 'easili':43 'ecosystem':29 'enabl':40 'featur':67 'generat':5,20,70 'integr':44 'interact':18 'interfac':33 'languag':37 'larg':36 'librari':51 'llm':72 'llms':39 'maintain':58 'model':38 'new':66 'particular':25 'provid':31 'python':13 'regular':60 'releas':61 'sap':1,8,28,68 'sdk':3,10 'servic':24 'simplifi':17 'unifi':32 'updat':64 'various':35 'version':55 'within':26","created_at":"2026-04-16T18:49:27.553573+00:00","updated_at":"2026-04-16T18:49:27.553573+00:00","problems":null,"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"6.10.0","cli_name":"","cli_version":null,"type":"library","homepage":"https://www.sap.com/","github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/sap-ai-sdk-gen/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["llm-agents","ai-ml"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-30","last_verified":"2026-06-30","next_check":"2026-07-30","install_tag":null}}