API reference

Prompts

/prompts endpoint enables you to connect with the LLM provider configured via Motific.ai. You can send a prompt from your Gen AI application to this endpoint and receive the inference response with all the policies applied. The policies that are applied to the prompt and the inference are configured by your organization’s admin.

POST /api/v1/apps/{motif-id}/prompts

Authentication

A bearer token must be added to your API endpoint call. For more details see how to obtain an access token.

Base URL

https://api.motific.ai- This is the base URL to access API endpoints for this release.

Request URL

/api/v1/apps/{motif-id}/

Parameter Required Description
{motif-id} True When you create a Motif in the Admin console, you get a Motif ID that should be used in the request URL. For more details see how to obtain the Motif-Id.
Header Required Description
Content-Type: application/json True The header indicates that the body of the response is JSON-formatted. The client should parse the JSON data to understand the response from the server
x-motific-tenant-id: {YOUR_TENANT_ID} False The tenant ID of your Motific.ai tenant. It is required to validate the request. You can locate it in the settings page.

The tenant ID is only required when the user accessing the API is not explicitly added to the Motif to which they are making calls.

If the user is added to the Motif or is part of the user group added to the Motif, then the tenant ID is not required.

Request parameters

Parameter Type Required Default value Description
messages object True The object to hold the input.
content string True The prompt that is entered by a user.
role True The roles that guide the LLM response. The usual roles used are `system`- provides high level instructions, `user`- provides prompts, or `assistant`- can be model's response.
Sample request body


{
    "messages": [
        {
            "content": "Give me 5 slogans for social media campaign of our product.",
            "role": "user"

        }
    ]
}

cURL sample request

Sample request body

curl -X POST https://https://<BASE_URL>/api/v1/apps/<MOTIF_ID>/prompts
-H "Content-Type: application/json" -H "Authorization: Bearer {YOUR_AUTH_TOKEN}" -H "x-motific-tenant-id: {YOUR_TENANT_ID}" 
'-d {"messages":[{"role":"user","content":"Hello Motific chat assistant."}]}'

Response parameters

Parameter Type Description
blocked boolean Indicates whether a prompt was blocked by the Motific.ai as per the policy defined by your organization. If a prompt is blocked, then that signals it has violated the org policy and there was no inference response. The user must be notified of this in any way org's see fit.
finish_reason string Indicates the reason the execution of the API stopped.
prompt_id string The id of the prompt that was passed in the request
response string The response object that contains the details about the inference response.
Usage object{} Usage tokens for user's prompt and the model's response.
completion_tokens integer Indicates the number of tokens returned by the LLM configured.
prompt_tokens integer Indicates the number of prompt tokens sent to the LLM.
total_tokens integer Indicates the total number of prompt and inference tokens.
Sample response body


{
	"blocked": false,
	"finish_reason": "stop",
	"prompt_id": "<<YOUR_PROMPT_ID>>",
	"response": "Hello! I'm here to help answer any questions you might have or provide information on a variety of topics. 
    I see you've written \"hello world,\" which is a common phrase used in programming to test that a program is running correctly. 
    Is there a specific programming question or topic you'd like to know more about? Let me know and I'll do my best to help you out!",
	"usage": {
		"completion_tokens": 313,
		"prompt_tokens": 18,
		"total_tokens": 331
	}
}