### Metadata Handling Example Source: https://help.sap.com/docs/sap-ai-core/generative-ai/contextualized-retrieval-using-metadata-and-vector-search-911c1ca88d3243e4ab34509d08ceb962 An example demonstrating how to handle metadata, specifically showing a naming convention for duplicate metadata keys across different levels (chunk and document). ```json "metadata": { "webUrl": "", "document_webUrl": "" } ``` -------------------------------- ### Output Code Example Source: https://help.sap.com/docs/sap-ai-core/generative-ai/contextualized-retrieval-using-metadata-and-vector-search-911c1ca88d3243e4ab34509d08ceb962 This JSON output shows an example of the response when metadata like source and webUrl is included. ```json [ [ { "content": "Joule is the AI copilot that truly understands your business. Joule revolutionizes how you interact with your SAP business systems, making every touchpoint count and every task simpler.", "metadata": { "source": [ "/tmp/document_1.pdf" ], "webUrl": [ "https:///sites//sap_joule.pdf" ], "document_webUrl": [ "https:///sites//sap_joule.pdf" ] } }, { "content": "AI-powered capabilities in Joule with custom-developed enterprise skills tailored to your company's specific needs. By integrating with both SAP and third-party applications, Joule can instantly apply its newfound knowledge within SAP systems.", "metadata": { "source": [ "/tmp/document_1.pdf" ], "webUrl": [ "https:///sites//sap_joule.pdf" ], "document_webUrl": [ "https:///sites//sap_joule.pdf" ] } } ] ] ``` -------------------------------- ### Prompt Templating Example Source: https://help.sap.com/docs/sap-ai-core/generative-ai/contextualized-retrieval-using-metadata-and-vector-search This snippet shows an example of prompt templating, including message history and defaults, for a helpful assistant that uses grounding requests and outputs. ```json "prompt_templating": { "messages_history": [ { "role": "user", "content": "You are a helpful assistant for any queries for SAP Teched 2024.\nAnswer the grounding request by providing relevant answers that fit to the request. \n\nRequest: {{ ?groundingRequest }}\n\nReports:{{ ?groundingOutput }} Alongwith the original response, provide another response by making use of metadata received in the grounding output to provide more optimal response. Explain how the metadata was used." } ], "defaults": {} } ``` -------------------------------- ### User Role Content Example Source: https://help.sap.com/docs/sap-ai-core/generative-ai/contextualized-retrieval-using-metadata-and-vector-search-911c1ca88d3243e4ab34509d08ceb962 An example of JSON content defining a user role for an assistant, including a prompt structure for SAP Teched 2024 queries. ```json { "role": "user", "content": "You are a helpful assistant for any queries for SAP Teched 2024.\nAnswer the grounding request by providing relevant answers that fit to the request. \n\nRequest: {{ ?groundingRequest }}\n\nReports:{{ ?groundingOutput }} Alongwith the original response, provide another response by making use of metadata received in the grounding output to provide more optimal response. Explain how the metadata was used." } ``` -------------------------------- ### Example Output of Available Models Source: https://help.sap.com/docs/sap-ai-core/generative-ai/choose-model This is an example of the JSON output returned when querying the available models endpoint, showing details for GPT-4o. ```json { "count": 41, "resources": [ { "accessType": "Remote", "allowedScenarios": [ { "executableId": "azure-openai", "scenarioId": "foundation-models" }, { "executableId": "orchestration", "scenarioId": "orchestration" } ], "description": "OpenAI GPT-4o engineered for speed and efficiency, supporting text, images and audio using Chat Completions API", "displayName": "GPT-4o", "executableId": "azure-openai", "model": "gpt-4o", "provider": "OpenAI", "versions": [ { "capabilities": [ "text-generation", "image-recognition" ], "contextLength": 128000, "cost": [ { "inputCost": "0.00312" }, { "outputCost": "0.0092" } ], "deprecated": false, "inputTypes": [ "text", "image", "audio" ], "isLatest": false, "metadata": [ { "meanWinRate": "0.938" }, { "chatBotArenaScore": "1285" }, { "airBenchRefusalRate": "0.528" } ], "name": "2024-05-13", "retirementDate": "", "streamingSupported": true }, ... ] } ``` -------------------------------- ### Get the Deployment URL Source: https://help.sap.com/docs/sap-ai-core/generative-ai/create-deployment-for-generative-ai-model Retrieves the details of a deployment by sending a GET request to the deployments endpoint with the deployment ID. ```curl curl --location '$AI_API_URL/v2/lm/deployments/$DEPLOYMENT_ID' \ --header 'AI-Resource-Group: default' \ --header "Authorization: Bearer $AUTH_TOKEN" ``` -------------------------------- ### AI Assistant Response Example Source: https://help.sap.com/docs/sap-ai-core/generative-ai/chat-cd16d739cf7b4c8aa5e3b12062ae6ce9 An example of a response from an AI assistant, including conversational content and usage details. ```json { "id": "chatcmpl-7v0n35364397234567890", "object": "chat.completion", "created": 1691274839, "model": "gpt-3.5-turbo-0613", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "1. In the depths of my soul, I find an eternal longing for thee, a love that transcends the bounds of time and space.\n2. Thou art the muse of my existence, inspiring a passion within me that resonates with the very essence of nature itself." }, "finish_reason": "stop" } ], "usage": { "completion_tokens": 55, "prompt_tokens": 212, "total_tokens": 267 } } ``` -------------------------------- ### Check Scenario Source: https://help.sap.com/docs/sap-ai-core/generative-ai/create-deployment-for-generative-ai-model Sends a GET request to check access to the scenario containing generative AI. ```curl curl --location '{{apiurl}}/v2/lm/scenarios' \ --header 'AI-Resource-Group: default' \ --header "Authorization: Bearer $AUTH_TOKEN" ``` -------------------------------- ### Successful Response Source: https://help.sap.com/docs/sap-ai-core/generative-ai/create-custom-metric Example JSON response upon successful creation of a custom metric. ```json { "message": "" "id": "" "scenario": "" "name": "" "version": "" } ``` -------------------------------- ### Amazon Nova Source: https://help.sap.com/docs/sap-ai-core/generative-ai/aws-bedrock Example of invoking the Amazon Nova model for conversational interaction. ```curl curl --location '$DEPLOYMENT_URL/converse' \ --header 'AI-Resource-Group: ' \ --header 'Content-Type: application/json' \ --header "Authorization: Bearer $AUTH_TOKEN" \ --data '{ "inferenceConfig": { "maxTokens": 100, "stopSequences": [ "blab" ], "temperature": 0.7 }, "messages": [ { "content": [ { "text": "Perplexity means?" } ], "role": "user" } ] }' ``` -------------------------------- ### View Available Models Source: https://help.sap.com/docs/sap-ai-core/generative-ai/choose-model Send a GET request to this endpoint to retrieve a list of available foundation models. ```shell curl --location '$AI_API_URL/v2/lm/scenarios/foundation-models/models' \ --header 'AI-Resource-Group: default' \ --header 'Authorization: Bearer $AUTH_TOKEN' ``` -------------------------------- ### Sample Code Source: https://help.sap.com/docs/sap-ai-core/generative-ai/check-batch-status Send a GET request to the endpoint to check the status of your batch job. ```curl curl -X GET "$AI_API/llm-batch-service/v1/batches/$BATCH_ID/status" \ -H 'AI-Resource-Group: ' \ -H 'Content-Type: application/json' \ -H "Authorization: Bearer $AUTH_TOKEN" \ ``` -------------------------------- ### Command A Reasoning API Call Source: https://help.sap.com/docs/sap-ai-core/generative-ai/cohere Example of how to call the Command A Reasoning model via API. ```curl curl --location "$DEPLOYMENT_URL/v2/chat" \ --header 'AI-Resource-Group: ' \ --header 'Content-Type: application/json' \ --header "Authorization: Bearer $AUTH_TOKEN" \ --data '{ \ "model": "cohere--command-a-reasoning", \ "stream": false, \ "frequency_penalty": 0.8, \ "thinking": { \ "type": "enabled" \ }, \ "messages": [ \ { \ "role": "user", \ "content": "Tell me about the reflection?" \ } \ ] \ }' ``` -------------------------------- ### Curl Request for Generative AI Completion Source: https://help.sap.com/docs/sap-ai-core/generative-ai/chat-cd16d739cf7b4c8aa5e3b12062ae6ce9 This example demonstrates how to make a POST request to the Generative AI completion endpoint using curl, including setting headers and providing a JSON payload with prompt templating and message history. ```bash curl --request POST $ORCH_DEPLOYMENT_URL/v2/completion \ --header 'content-type: application/json' \ --header "Authorization: Bearer $TOKEN" \ --header "AI-Resource-Group: $RESOURCE_GROUP" \ --data-raw '{ \ "config": { \ "modules": { \ "prompt_templating": { \ "prompt": { \ "template": [ \ { \ "role": "user", \ "content": "And now two more that sound like Goethe." \ } \ ] \ }, \ "model": { \ "name": "gpt-4o-mini", \ "params": { \ "max_completion_tokens": 300, \ "temperature": 0.1, \ "frequency_penalty": 0, \ "presence_penalty": 0 \ } \ } \ } \ } \ }, \ "placeholder_values": { \ }, \ "messages_history": [ \ { \ "role":"user", \ "content":"Create 3 paraphrases of I love you." \ }, \ { \ "role":"assistant", \ "content":"1. I have deep affection for you.\n2. My feelings for you are strong and caring.\n3. You mean everything to me." \ }, \ { \ "role":"user", \ "content":"Can you please make them more romantic." \ }, \ { \ "role":"assistant", \ "content":"1. My heart is filled with an intense passion for you.\n2. You are the light of my life, and my love for you knows no bounds.\n3. I cherish you more than words can express, my dear." \ }, \ { \ "role":"user", \ "content":"Try sounding like shakespeare." \ }, \ { \ "role":"assistant", \ "content":"1. Thou art the sun in my sky, and my love for thee doth burn with unyielding fervor.\n2. Within mine heart, thou hast ignited a flame of ardor that doth shine brightly for thee, my dearest.\n3. My love for thee doth surpass all measure, for thou art the true essence of my being." \ } \ ] \ }' ``` -------------------------------- ### Converse with Anthropic Claude Source: https://help.sap.com/docs/sap-ai-core/generative-ai/aws-bedrock Example curl command to converse with an Anthropic Claude model through the orchestration scenario. ```bash curl --location '$DEPLOYMENT_URL/converse' \ --header 'AI-Resource-Group: ' \ --header 'Content-Type: application/json' \ --header "Authorization: Bearer $AUTH_TOKEN" \ --data '{ \ "inferenceConfig": { \ "maxTokens": 100, \ "stopSequences": [ \ "blab" \ ] \ }, \ "messages": [ \ { \ "content": [ \ { \ "text": "Perplexity means?" \ } \ ], \ "role": "user" \ } \ ] \ }' ``` -------------------------------- ### Example cURL Request for Chat Completion Source: https://help.sap.com/docs/sap-ai-core/generative-ai/chat This snippet shows a cURL command to send a POST request to the completion endpoint, including message history and module configurations. ```bash curl --request POST $ORCH_DEPLOYMENT_URL/completion \ --header 'content-type: application/json' \ --header "Authorization: Bearer $TOKEN" \ --header "AI-Resource-Group: $RESOURCE_GROUP" \ --data-raw '{ \ "orchestration_config": { \ "module_configurations": { \ "templating_module_config": { \ "template": [ \ { \ "role": "user", \ "content": "And now two more that sound like Goethe." } \ ] }, "llm_module_config": { \ "model_name": "", \ "model_params": { \ "max_tokens": 300, \ "temperature": 0.1, \ "frequency_penalty": 0, \ "presence_penalty": 0 } } } }, "input_params": { }, "messages_history": [ { "role":"user", "content":"Create 3 paraphrases of I love you." }, { "role":"assistant", "content":"1. I have deep affection for you.\n2. My feelings for you are strong and caring.\n3. You mean everything to me." }, { "role":"user", "content":"Can you please make them more romantic." }, { "role":"assistant", "content":"1. My heart is filled with an intense passion for you.\n2. You are the light of my life, and my love for you knows no bounds.\n3. I cherish you more than words can express, my dear." }, { "role":"user", "content":"Try sounding like shakespeare." }, { "role":"assistant", "content":"1. Thou art the sun in my sky, and my love for thee doth burn with unyielding fervor.\n2. Within mine heart, thou hast ignited a flame of ardor that doth shine brightly for thee, my dearest.\n3. My love for thee doth surpass all measure, for thou art the true essence of my being." } ] }' ``` ``` -------------------------------- ### Invoke Anthropic Claude Source: https://help.sap.com/docs/sap-ai-core/generative-ai/aws-bedrock Example curl command to invoke an Anthropic Claude model through the orchestration scenario. ```bash curl --location '$DEPLOYMENT_URL/invoke' \ --header 'AI-Resource-Group: ' \ --header 'Content-Type: application/json' \ --header "Authorization: Bearer $AUTH_TOKEN" \ --data '{ \ "anthropic_version": "bedrock-2023-05-31", \ "max_tokens": 100, \ "messages": [ \ { \ "role": "user", \ "content": "Hello, Claude" \ } \ ] \ }' ``` -------------------------------- ### Rerank API Output Source: https://help.sap.com/docs/sap-ai-core/generative-ai/cohere Example JSON output from the Cohere Rerank API. ```json { "id": "", "meta": { "api_version": { "version": "1" }, "billed_units": { "search_units": 1 } }, "results": [ { "index": 2, "relevance_score": 0.85157084 }, { "index": 4, "relevance_score": 0.23100689 }, { "index": 1, "relevance_score": 0.056014005 } ] } ``` -------------------------------- ### Create Custom Metric Request Source: https://help.sap.com/docs/sap-ai-core/generative-ai/create-custom-metric Example cURL command to send a POST request to create a custom evaluation metric. ```curl curl --request POST \ --url $AI_API_URL/v2/lm/evaluationMetrics \ --header 'AI-Resource-Group: $RESOURCE_GROUP' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer $TOKEN' \ --data '{ \ "scenario": "qa-evaluation", \ "name": "factual-accuracy", \ "version": "1.0", \ "description": "Measures factual correctness of responses", \ "evaluationMethod": "llm-as-a-judge", \ "usageType": ["evaluation"], \ "includeProperties": ["prompt", "reference"], \ "spec": ... // Custom Metric Definition \ }' ``` -------------------------------- ### Check Deployment Status Source: https://help.sap.com/docs/sap-ai-core/generative-ai/create-deployment-for-orchestration This cURL command sends a GET request to check the status of the orchestration deployment using its ID. ```shell curl --request GET "$AI_API_URL/v2/lm/deployments/$ORCH_DEPLOYMENT_ID" \ --header "Authorization: Bearer $TOKEN" \ --header "AI-Resource-Group: $RESOURCE_GROUP" ``` -------------------------------- ### Titan Embed Image Source: https://help.sap.com/docs/sap-ai-core/generative-ai/aws-bedrock Example of invoking the Titan Embed Image model to generate embeddings from an image. ```curl curl --location '$DEPLOYMENT_URL/invoke' \ --header 'AI-Resource-Group: ' \ --header 'Content-Type: application/json' \ --header "Authorization: Bearer $AUTH_TOKEN" \ --data '{ "inputText": "hi", "inputImage": "#this-is-an-example-base64-string-value for-an-image/9j/4QDeRXhpZgAASUkqAAgAAAAGABIBAwABAAAAAQAAABoBBQABAAAAVgAAABsBBQABAAAAXgAAACgBAwABAAAAAgAAABMCAwABAAAAAQAAAGmHBAABAAAAZgAAAAAAAABIAAAAAQAAAEgAAAABAAAABwAAkAcABAAAADAyMTABkQcABAAAAAECAwCGkgcAFgAAAMAAAAAAoAcABAAAADAxMDABoAMAAQAAAP//AAACoAQAAQAAAMgAAAADoAQAAQAAAMgAAAAAAAAAQVNDSUkAAABQaWNzdW0gSUQ6IDEyM//bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicgIiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyM", "embeddingConfig": { "outputEmbeddingLength": 256 } }' ``` -------------------------------- ### Example JSON Response from Chat Completion Source: https://help.sap.com/docs/sap-ai-core/generative-ai/chat This snippet shows the JSON response structure from a chat completion request, including module results and orchestration results. ```json { "request_id": "5445f8d8-8b68-43c3-a149-26c1e6a88a22", "module_results": { "templating": [ { "role": "user", "content": "Create 3 paraphrases of I love you." }, { "role": "assistant", "content": "1. I have deep affection for you.\n2. My feelings for you are strong and caring.\n3. You mean everything to me." }, { "role": "user", "content": "Can you please make them more romantic." }, { "role": "assistant", "content": "1. My heart is filled with an intense passion for you.\n2. You are the light of my life, and my love for you knows no bounds.\n3. I cherish you more than words can express, my dear." }, { "role": "user", "content": "Try sounding like shakespeare." }, { "role": "assistant", "content": "1. Thou art the sun in my sky, and my love for thee doth burn with unyielding fervor.\n2. Within mine heart, thou hast ignited a flame of ardor that doth shine brightly for thee, my dearest.\n3. My love for thee doth surpass all measure, for thou art the true essence of my being." }, { "role": "user", "content": "And now two more that sound like Goethe." } ], "llm": { "id": "chatcmpl-9kXqisJKnuNv1B4eXTUzqZEJSmzdC", "object": "chat.completion", "created": 1720880232, "model": "", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "1. In thy presence, my soul finds solace, for thou art the embodiment of love's sweetest melody.\n2. Like a gentle breeze upon a summer's eve, thy love doth caress my heart and fill it with eternal longing." }, "finish_reason": "stop" } ], "usage": { "completion_tokens": 51, "prompt_tokens": 212, "total_tokens": 263 } } }, "orchestration_result": { "id": "chatcmpl-9kXqisJKnuNv1B4eXTUzqZEJSmzdC", "object": "chat.completion", "created": 1720880232, "model": "", "choices": [ { "index": 0, "message": { "role": "assistant", ``` -------------------------------- ### Rerank 3.5 API Call Source: https://help.sap.com/docs/sap-ai-core/generative-ai/cohere Example curl command to call the Cohere Rerank 3.5 model for document reranking. ```curl curl --location "$DEPLOYMENT_URL/rerank" \ --header 'AI-Resource-Group: ' \ --header 'Content-Type: application/json' \ --header "Authorization: Bearer $AUTH_TOKEN" \ --data '{ "model": "cohere-reranker-35", "top_n": 3, "query": "What is the capital of Amesic?", "documents": [ "Carson City is the capital city of the American state of Strita.", "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.", "Anesia, D.C. is the capital of the Amesic States. It is a federal district.", "Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages.", "Capital punishment has existed in the Amesic since before it was a country. As of 2017, capital punishment is legal in 30 of the 50 states." ] }' ``` -------------------------------- ### Invoke Amazon Titan Embed Text Source: https://help.sap.com/docs/sap-ai-core/generative-ai/aws-bedrock Example curl command to invoke Amazon Titan Embed Text model through the orchestration scenario. ```bash curl --location '$DEPLOYMENT_URL/invoke' \ --header 'AI-Resource-Group: ' \ --header 'Content-Type: application/json' \ --header "Authorization: Bearer $AUTH_TOKEN" \ --data '{ \ "inputText": "Who im I?" \ }' ``` -------------------------------- ### Sample Code for Creating a Configuration Source: https://help.sap.com/docs/sap-ai-core/generative-ai/create-configuration-for-optimization This cURL command demonstrates how to create a configuration for optimization by sending a POST request to the AI API. ```curl curl --request POST "$AI_API_URL/v2/lm/configurations" \ --header "Authorization: Bearer $TOKEN" \ --header "AI-Resource-Group: $RESOURCE_GROUP" \ --header "Content-Type: application/json" \ --data '{ \ "name": "genai-eval-conf", \ "scenarioId": "genai-optimizations ", \ "executableId": "genai-optimizations ", \ "inputArtifactBindings": [ \ { \ "key": "datasetFolder", \ "artifactId": "1f50fbf8-18d6-4e72-ae10-04fdbc087815" \ } \ ], \ "parameterBindings": [ \ { \ "key": "basePrompt", \ "value": "/:" \ }, \ { \ "key": "dataset", \ "value": "data.json" \ { \ "key": "optimizationMetric", \ "value": "JSON_Match” \ }, \ { \ "key": "promptTemplateScope", \ "value": "resourcegroup" \ }, { \ "key": "targetModels", \ "value": ":” \ }, \ { \ "key": "targetPromptMapping", \ "value": “:=:” \ } \ ] \ }' ``` -------------------------------- ### Create a Configuration Source: https://help.sap.com/docs/sap-ai-core/generative-ai/create-deployment-for-generative-ai-model Sends a POST request to create a configuration for a model, including its name, executable ID, scenario ID, version ID, and parameter bindings for model name and version. ```curl curl --location '$AI_API_URL/v2/lm/configurations' \ --header 'AI-Resource-Group: default' \ --header 'Content-Type: application/json' \ --header "Authorization: Bearer $AUTH_TOKEN" \ --data '{ "name": "yourNameChoice", "executableId": "", "scenarioId": "foundation-models", "versionId": "0.0.1", "parameterBindings": [ { "key":"modelName", "value":"" }, { "key": "modelVersion", "value": "" } ] }' ``` -------------------------------- ### Note on using trainDataset and testDataset Source: https://help.sap.com/docs/sap-ai-core/generative-ai/create-configuration-for-optimization This snippet shows how to modify the dataset key-value pairs to use trainDataset and testDataset. ```json { "key": "trainDataset", "value": "train-dataset.json", } { "key": "testDataset", "value": "test-dataset.json", } ``` -------------------------------- ### Sample Code Source: https://help.sap.com/docs/sap-ai-core/generative-ai/create-collection-c124fb9b68864fa187243ee4edcf213c This sample code demonstrates how to create a new collection using a POST request to the specified endpoint. ```curl curl --request POST \ --url $AI_API_URL/v2/lm/document-grounding/vector/collections \ --header 'AI-Resource-Group: {{resource_group}}' \ --header 'Authorization: Bearer {{access_token}}' --data '{ "id": "", "title": "", "embeddingConfig": { "modelName": "<embedding-model-name>" }, "metadata": [ { "key": "purpose", "value": [ "<text>" ] }, { "key": "<a-random-key>", "value": [ "<text>" ] } ] }' ``` -------------------------------- ### Create a Deployment Source: https://help.sap.com/docs/sap-ai-core/generative-ai/create-deployment-for-generative-ai-model Sends a POST request to create a deployment using the configuration ID obtained from the previous step. ```curl curl --location '$AI_API_URL/v2/lm/deployments' \ --header 'AI-Resource-Group: default' \ --header 'Content-Type: application/json' \ --header "Authorization: Bearer $AUTH_TOKEN" \ --data '{ "configurationId": "yourConfigurationId" }' ``` -------------------------------- ### Leverage Metadata in Prompt Source: https://help.sap.com/docs/sap-ai-core/generative-ai/contextualized-retrieval-using-metadata-and-vector-search-911c1ca88d3243e4ab34509d08ceb962 This JSON snippet shows how to include instructions in the prompt for how the model should use the metadata, within the prompt_templating configuration. ```json "prompt_templating": { "messages_history": [ ``` -------------------------------- ### Sample Code Source: https://help.sap.com/docs/sap-ai-core/generative-ai/create-batch-job Submit a batch job by sending a POST request to the endpoint $AI_API/llm-batch-service/v1/batches. ```curl curl -X POST "$AI_API/llm-batch-service/v1/batches" \ -H 'AI-Resource-Group: <resource_group>' \ -H 'Content-Type: application/json' \ -H "Authorization: Bearer $AUTH_TOKEN" \ -D '{ \ "type": "llm-native", \ "input": { \ "uri": "ai://<object_store_secret_name>/<input_file>.jsonl" \ }, \ "output": { \ "uri": "ai://<object_store_secret_name>/<output_folder>/" \ }, \ "spec": { \ "provider": "azure-openai", \ "model": "gpt-4.1" \ } \ }' ``` -------------------------------- ### Create Configuration for Orchestration Deployment Source: https://help.sap.com/docs/sap-ai-core/generative-ai/create-deployment-for-orchestration This cURL command sends a POST request to create a configuration for an orchestration deployment. ```shell curl --request POST "$AI_API_URL/v2/lm/configurations" \ --header "Authorization: Bearer $TOKEN" \ --header "AI-Resource-Group: $RESOURCE_GROUP" \ --header "Content-Type: application/json" \ --data-raw '{ "name": "orchestration-config", "executableId": "orchestration", "scenarioId": "orchestration" }' ``` -------------------------------- ### Retrieve Supported Metadata Keys Source: https://help.sap.com/docs/sap-ai-core/generative-ai/contextualized-retrieval-using-metadata-and-vector-search-911c1ca88d3243e4ab34509d08ceb962 This cURL command demonstrates how to retrieve supported metadata keys by querying the retrieval search endpoint. ```curl curl --request POST \ --url {{AI_API_URL}}/v2/lm/document-grounding/retrieval/search \ --header 'AI-Resource-Group: <resource_group>' \ --header 'Authorization: Bearer <access_token>' \ --header 'Content-Type: application/json' \ --data '{ \ "query": "what is SAP Joule", \ "filters": [ \ { \ "id": "string", \ "searchConfiguration": { \ "maxChunkCount": 5 \ }, \ "dataRepositories": [ \ "*" \ ], \ "dataRepositoryType": "vector", \ "dataRepositoryMetadata": [ \ { \ "key": "type", \ "value": [ \ "custom" \ ] \ } \ ], \ "documentMetadata": [], \ "chunkMetadata": [] \ } \ ] \ }' ``` -------------------------------- ### Sample Code Source: https://help.sap.com/docs/sap-ai-core/generative-ai/consume-models-with-harmonized-api A minimal call to orchestration contains only configurations of the required templating and model configuration modules. ```curl curl --request POST $ORCH_DEPLOYMENT_URL/v2/completion \ --header 'content-type: application/json' \ --header "Authorization: Bearer $TOKEN" \ --header "AI-Resource-Group: $RESOURCE_GROUP" \ --data-raw '{ "config": { "modules": { "prompt_templating": { "prompt": { "template": [ { "role": "user", "content": "Reply with `{{?text}}` in {{?language}}" } ], "defaults": { "language": "English" } }, "model": { "name": "<model>", "params": { "max_completion_tokens": 50, "temperature": 0.1, "frequency_penalty": 0, "presence_penalty": 0 } } } } }, "placeholder_values": { "text": "Orchestration is Working!", "language": "German" } }' ``` -------------------------------- ### Create Deployment for Orchestration Source: https://help.sap.com/docs/sap-ai-core/generative-ai/create-deployment-for-orchestration This cURL command sends a POST request to create a deployment for orchestration using the provided configuration ID. ```shell curl --request POST $AI_API_URL/v2/lm/deployments \ --header 'content-type: application/json' \ --header "Authorization: Bearer $TOKEN" \ --header "AI-Resource-Group: $RESOURCE_GROUP" \ --data-raw "{ \"configurationId\": \"$ORCH_CONFIG_ID\" }" ``` -------------------------------- ### Set Deployment URL as Environment Variable Source: https://help.sap.com/docs/sap-ai-core/generative-ai/create-deployment-for-orchestration This command sets the deployment URL as an environment variable, which is available when the deployment status is RUNNING. ```shell ORCH_DEPLOYMENT_URL="<deployment_url>" ``` -------------------------------- ### Sample Code Source: https://help.sap.com/docs/sap-ai-core/generative-ai/batch-update-document-metadata This sample code demonstrates how to send a PATCH request to update document metadata. ```curl curl --request PATCH \ --url $AI_API_URL/v2/lm/document-grounding/pipelines/metadata/configurations/<metadataConfigId>/documents/<documentId> \ --header 'AI-Resource-Group: <resource_group>' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer $TOKEN' \ --data '{ "value": [ { "id": "<documentId>", "metadata": [ { "key": "contentObjectId", "value": [ "12345" ], "matchMode": "ANY" } ] } ]' ``` -------------------------------- ### Include Metadata in Request Source: https://help.sap.com/docs/sap-ai-core/generative-ai/contextualized-retrieval-using-metadata-and-vector-search This `curl` command shows how to include metadata like 'source' and 'webUrl' in the results by using `metadata_params`. ```shell curl --request POST "$ORCH_DEPLOYMENT_URL/completion" \ --header "content-type: application/json" \ --header "Authorization: Bearer $TOKEN" \ --header "AI-Resource-Group: $RESOURCE_GROUP" \ --data '{ \ "orchestration_config": { \ "module_configurations": { \ "grounding_module_config": { \ "type": "document_grounding_service", \ "config": { \ "filters": [ \ { \ "id": "filter1", \ "data_repositories": [ \ "*" \ ], \ "search_config": {}, \ "data_repository_type": "vector" \ } \ ], \ "input_params": [ \ "groundingRequest" \ ], \ "output_param": "groundingOutput", \ "metadata_params": [ \ "source", \ "webUrl" \ ] \ \ } \ }, \ "llm_module_config": { \ "model_name": "gemini-1.5-pro", \ "model_params": {}, \ "model_version": "001" \ }, \ "templating_module_config": { \ "template": [ \ { \ "role": "user", \ "content": "You are a helpful assistant for any queries for SAP Teched 2024.\nAnswer the grounding request by providing relevant answers that fit to the request. \n\nRequest: {{ ?groundingRequest }}" \ } \ ], \ "defaults": {} \ }, \ "filtering_module_config": { \ "input": { \ "filters": [ \ { \ "type": "azure_content_safety", \ "config": { \ "Hate": 2, \ "SelfHarm": 2, \ "Sexual": 2, \ "Violence": 2 \ } \ } \ ] \ }, \ "output": { \ "filters": [ \ { \ "type": "azure_content_safety", \ "config": { \ "Hate": 2, \ "SelfHarm": 2, \ "Sexual": 2, \ "Violence": 2 \ } \ } \ ] \ } \ } \ } \ }, \ "input_params": { \ "groundingRequest": "what is SAP Joule?" \ } \ }' ``` -------------------------------- ### Set Orchestration Configuration ID as Environment Variable Source: https://help.sap.com/docs/sap-ai-core/generative-ai/create-deployment-for-orchestration This command sets the ID of the created orchestration configuration as an environment variable. ```shell ORCH_CONFIG_ID=f7ac7f77-e70f-4e9c-86b5-1504b44fe789 ``` -------------------------------- ### Include Metadata in Request Source: https://help.sap.com/docs/sap-ai-core/generative-ai/contextualized-retrieval-using-metadata-and-vector-search-911c1ca88d3243e4ab34509d08ceb962 This cURL command shows how to include metadata (source and webUrl) in the results by configuring the grounding service with metadata_params. ```curl curl --request POST \ --url {{ORCH_DEPLOYMENT_URL}}/v2/completion \ --header 'Authorization: Bearer <access_token>' \ --header 'AI-Resource-Group: <resource_group>' \ --header 'content-type: application/json' \ --data '{ \ "config": { \ "modules": { \ "grounding": { \ "type": "document_grounding_service", \ "config": { \ "filters": [ \ { \ "id": "filter1", \ "data_repositories": [ \ "*" \ ], \ "search_config": { \ "max_chunk_count": 100 \ }, \ "data_repository_type": "vector" \ } \ ], \ "placeholders": { \ "input": [ \ "groundingRequest" \ ], \ "output": "groundingOutput" \ }, \ "metadata_params": [ \ "source", \ "webUrl" \ ] \ \ } \ }, \ "prompt_templating": { \ "prompt": { \ "template": [ \ { \ "role": "user", \ "content": "<prompt>: {{?groundingRequest}} Reports: {{?groundingOutput}}" \ } \ ] \ }, \ "model": { \ "name": "<modelName>", \ "version": "<modelVersion>", \ "params": { \ "max_completion_tokens": 50, \ "temperature": 0.1, \ "frequency_penalty": 0, \ "presence_penalty": 0 \ } \ } \ } \ } \ }, \ "placeholder_values": { \ "groundingRequest": "what is SAP Joule?" \ } \ }' ``` -------------------------------- ### Output Code Source: https://help.sap.com/docs/sap-ai-core/generative-ai/create-batch-job The service schedules the job for processing and returns a unique batch ID. ```json { "id": "550e8400-e29b-41d4-a716-446655440000", "created_at": "2026-01-07T10:30:00Z", "status": "PENDING", "message": "Batch job scheduled" } ``` -------------------------------- ### Set Orchestration Deployment ID as Environment Variable Source: https://help.sap.com/docs/sap-ai-core/generative-ai/create-deployment-for-orchestration This command sets the ID of the created orchestration deployment as an environment variable. ```shell ORCH_DEPLOYMENT_ID=d4168482710c6cf9 ``` -------------------------------- ### Create Document Request Source: https://help.sap.com/docs/sap-ai-core/generative-ai/create-document This cURL command demonstrates how to send a POST request to the endpoint to add a document to a collection, including metadata and chunks. ```curl curl --request POST \ --url $AI_API_URL/v2/lm/document-grounding/vector/collections/{{collectionId}}/documents\ --header 'AI-Resource-Group: {{resource_group}}' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer {{access_token}}'\ --data '{ "documents": [ { "metadata": [ { "key": "url", "value": [ "http://hello.com", "123" ] } ], "chunks": [ { "content": "<chunk content 1>", "metadata": [ // { "key": "index", "value": [ "1" ] } ] }, { "content": "<chunk content 2>", "metadata": [ { "key": "index", "value": [ "2" ] } ] } ] } ] }' ``` -------------------------------- ### Output Code Source: https://help.sap.com/docs/sap-ai-core/generative-ai/batch-update-document-metadata A successful response returns code 200 and includes details of the document in JSON format. ```json { "id": "document-uuid", "metadata": [...] } ``` -------------------------------- ### Adding Labels Source: https://help.sap.com/docs/sap-ai-core/generative-ai/adding-to-inference-record Send a POST request to the endpoint to add labels to an inference record. Include the inference ID and labels as key-value pairs in the body. ```curl curl --request POST \ --url $AI_API/observability/inferences/{{inferenceId}}/labels \ --header 'ai-resource-group: <resource_group>' \ --header 'authorization: Bearer $TOKEN' \ --header 'content-encoding: application/json' \ --header 'content-type: application/json' \ --data '[ { "key": "ext.ai.sap.com/<key>", "value": "<value>" } ]' ``` -------------------------------- ### Output Code Source: https://help.sap.com/docs/sap-ai-core/generative-ai/check-batch-status The response includes the current status of your batch. ```json { "current_status": "IN_PROGRESS", "target_status": "COMPLETED", "updated_at": "2026-01-07T10:35:00Z", "message": "Processing batch requests" } ```