> For the complete documentation index, see [llms.txt](https://raia2.gitbook.io/raia/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://raia2.gitbook.io/raia/api-reference/prompts.md).

# Prompts

## Process a prompt request

> Processes a user prompt and returns an AI-generated response. The request must contain a valid API key.

```json
{"openapi":"3.0.0","info":{"title":"AI Agent API","version":"1.0.0"},"servers":[{"url":"https://api.raia2.com","description":"Production server"}],"security":[{"Agent-Secret-Key":[]}],"components":{"securitySchemes":{"Agent-Secret-Key":{"type":"apiKey","in":"header","name":"Agent-Secret-Key","description":"Custom authentication header"}},"schemas":{"ProcessPromptBodyDTO":{"type":"object","properties":{"prompt":{"type":"string","description":"The question that the user sends to the AI agent"},"tokenTrackingId":{"type":"string","description":"The ID of the token tracking"},"files":{"description":"Files attached to the message","type":"array","items":{"$ref":"#/components/schemas/PromptFileBodyDTO"}}},"required":["prompt"]},"PromptFileBodyDTO":{"type":"object","properties":{"fileName":{"type":"string","description":"File name"},"storagePath":{"type":"string","description":"Storage path"}},"required":["fileName","storagePath"]},"ProcessPromptResponseDTO":{"type":"object","properties":{"status":{"type":"string","enum":["pending","completed","failed"],"description":"Response status"},"totalTokens":{"type":"number","description":"Total number of tokens used for the request","nullable":true},"usage":{"description":"Token usage for a completed prompt run. Token counts are aggregated across model calls; model metadata describes the last model used.","nullable":true,"type":"object","allOf":[{"$ref":"#/components/schemas/PromptTokenUsageDTO"}]},"response":{"type":"string","description":"The AI-generated response to the user prompt","nullable":true},"error":{"type":"string","description":"Response error","nullable":true}},"required":["status","totalTokens","usage","response","error"]},"PromptTokenUsageDTO":{"type":"object","properties":{"model":{"type":"string","description":"Model reported for the prompt run. For multi-model runs, this is the last model used.","nullable":true},"modelProvider":{"type":"string","description":"Provider of the reported model","nullable":true},"reasoningEffort":{"type":"string","description":"Reasoning effort used by the reported model","nullable":true},"reasoningMode":{"type":"string","description":"Reasoning mode used by the reported model","nullable":true},"inputTokens":{"type":"number","description":"Aggregate number of input tokens used for the prompt run"},"outputTokens":{"type":"number","description":"Aggregate number of output tokens used for the prompt run"},"reasoningTokens":{"type":"number","description":"Aggregate number of reasoning tokens used for the prompt run. Returns 0 for non-reasoning models."},"totalTokens":{"type":"number","description":"Aggregate total number of tokens used for the prompt run"}},"required":["model","modelProvider","reasoningEffort","reasoningMode","inputTokens","outputTokens","reasoningTokens","totalTokens"]},"ForbiddenErrorDTO":{"type":"object","properties":{"status":{"type":"number","default":403},"name":{"type":"object","default":"FORBIDDEN_ERROR"},"message":{"type":"string","default":"INVALID_CREDENTIALS"},"details":{"type":"array","items":{"type":"object"}}},"required":["status","name","message","details"]},"InternalServerErrorDTO":{"type":"object","properties":{"status":{"type":"number","default":500},"message":{"type":"string","default":"Internal Server Error"}},"required":["status","message"]}}},"paths":{"/external/prompts":{"post":{"description":"Processes a user prompt and returns an AI-generated response. The request must contain a valid API key.","operationId":"ExternalApiPromptsController_processPromptSync","parameters":[],"requestBody":{"required":true,"description":"Provide the prompt text to process.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProcessPromptBodyDTO"}}}},"responses":{"200":{"description":"Successfully processed the prompt and returned a response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProcessPromptResponseDTO"}}}},"403":{"description":"Invalid API key or secret key. Ensure that you are using a valid authentication key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ForbiddenErrorDTO"}}}},"429":{"description":"Rate limit exceeded. Each organization is limited to 300 requests per 60 seconds for AI-backed external API operations."},"500":{"description":"Unexpected error occurred while processing the request. Please try again later.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalServerErrorDTO"}}}}},"summary":"Process a prompt request","tags":["Prompts","Agent API Key"]}}}}
```

## Create a prompt request

> Creates a user prompt and returns an ID. The request must contain a valid API key.

```json
{"openapi":"3.0.0","info":{"title":"AI Agent API","version":"1.0.0"},"servers":[{"url":"https://api.raia2.com","description":"Production server"}],"security":[{"Agent-Secret-Key":[]}],"components":{"securitySchemes":{"Agent-Secret-Key":{"type":"apiKey","in":"header","name":"Agent-Secret-Key","description":"Custom authentication header"}},"schemas":{"CreatePromptBodyDTO":{"type":"object","properties":{"prompt":{"type":"string","description":"The question that the user sends to the AI agent"},"tokenTrackingId":{"type":"string","description":"The ID of the token tracking"},"files":{"description":"Files attached to the message","type":"array","items":{"$ref":"#/components/schemas/PromptFileBodyDTO"}}},"required":["prompt"]},"PromptFileBodyDTO":{"type":"object","properties":{"fileName":{"type":"string","description":"File name"},"storagePath":{"type":"string","description":"Storage path"}},"required":["fileName","storagePath"]},"CreatePromptResponseDTO":{"type":"object","properties":{"promptId":{"type":"string","description":"The ID of the prompt"}},"required":["promptId"]},"ForbiddenErrorDTO":{"type":"object","properties":{"status":{"type":"number","default":403},"name":{"type":"object","default":"FORBIDDEN_ERROR"},"message":{"type":"string","default":"INVALID_CREDENTIALS"},"details":{"type":"array","items":{"type":"object"}}},"required":["status","name","message","details"]},"InternalServerErrorDTO":{"type":"object","properties":{"status":{"type":"number","default":500},"message":{"type":"string","default":"Internal Server Error"}},"required":["status","message"]}}},"paths":{"/external/prompts/async":{"post":{"description":"Creates a user prompt and returns an ID. The request must contain a valid API key.","operationId":"ExternalApiPromptsController_createPromptJob","parameters":[],"requestBody":{"required":true,"description":"Provide the prompt text to process.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreatePromptBodyDTO"}}}},"responses":{"200":{"description":"Successfully created the prompt and returned an ID.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreatePromptResponseDTO"}}}},"403":{"description":"Invalid API key or secret key. Ensure that you are using a valid authentication key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ForbiddenErrorDTO"}}}},"429":{"description":"Rate limit exceeded. Each organization is limited to 300 requests per 60 seconds for AI-backed external API operations."},"500":{"description":"Unexpected error occurred while processing the request. Please try again later.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalServerErrorDTO"}}}}},"summary":"Create a prompt request","tags":["Prompts","Agent API Key"]}}}}
```

## Get a response on prompt request

> Returns a response on a user prompt by ID. The request must contain a valid API key.

```json
{"openapi":"3.0.0","info":{"title":"AI Agent API","version":"1.0.0"},"servers":[{"url":"https://api.raia2.com","description":"Production server"}],"security":[{"Agent-Secret-Key":[]}],"components":{"securitySchemes":{"Agent-Secret-Key":{"type":"apiKey","in":"header","name":"Agent-Secret-Key","description":"Custom authentication header"}},"schemas":{"GetResponseOnPromptResponseDTO":{"type":"object","properties":{"status":{"type":"string","enum":["pending","completed","failed"],"description":"Response status"},"totalTokens":{"type":"number","description":"Total number of tokens used for the request","nullable":true},"usage":{"description":"Token usage for a completed prompt run. Token counts are aggregated across model calls; model metadata describes the last model used.","nullable":true,"type":"object","allOf":[{"$ref":"#/components/schemas/PromptTokenUsageDTO"}]},"response":{"type":"string","description":"The AI-generated response to the user prompt","nullable":true},"error":{"type":"string","description":"Response error","nullable":true}},"required":["status","totalTokens","usage","response","error"]},"PromptTokenUsageDTO":{"type":"object","properties":{"model":{"type":"string","description":"Model reported for the prompt run. For multi-model runs, this is the last model used.","nullable":true},"modelProvider":{"type":"string","description":"Provider of the reported model","nullable":true},"reasoningEffort":{"type":"string","description":"Reasoning effort used by the reported model","nullable":true},"reasoningMode":{"type":"string","description":"Reasoning mode used by the reported model","nullable":true},"inputTokens":{"type":"number","description":"Aggregate number of input tokens used for the prompt run"},"outputTokens":{"type":"number","description":"Aggregate number of output tokens used for the prompt run"},"reasoningTokens":{"type":"number","description":"Aggregate number of reasoning tokens used for the prompt run. Returns 0 for non-reasoning models."},"totalTokens":{"type":"number","description":"Aggregate total number of tokens used for the prompt run"}},"required":["model","modelProvider","reasoningEffort","reasoningMode","inputTokens","outputTokens","reasoningTokens","totalTokens"]},"ForbiddenErrorDTO":{"type":"object","properties":{"status":{"type":"number","default":403},"name":{"type":"object","default":"FORBIDDEN_ERROR"},"message":{"type":"string","default":"INVALID_CREDENTIALS"},"details":{"type":"array","items":{"type":"object"}}},"required":["status","name","message","details"]},"InternalServerErrorDTO":{"type":"object","properties":{"status":{"type":"number","default":500},"message":{"type":"string","default":"Internal Server Error"}},"required":["status","message"]}}},"paths":{"/external/prompts/{id}/response-on":{"get":{"description":"Returns a response on a user prompt by ID. The request must contain a valid API key.","operationId":"ExternalApiPromptsController_getResponseOnPrompt","parameters":[{"name":"id","required":true,"in":"path","description":"Provide the prompt ID to process.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successfully returned a response on the prompt. Returns null if the prompt is not ready.","schema":{"oneOf":[{"$ref":"#/components/schemas/GetResponseOnPromptResponseDTO"},{"type":"null"}]},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetResponseOnPromptResponseDTO"}}}},"403":{"description":"Invalid API key or secret key. Ensure that you are using a valid authentication key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ForbiddenErrorDTO"}}}},"429":{"description":"Rate limit exceeded. Each organization is limited to 300 requests per 60 seconds for AI-backed external API operations."},"500":{"description":"Unexpected error occurred while processing the request. Please try again later.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalServerErrorDTO"}}}}},"summary":"Get a response on prompt request","tags":["Prompts","Agent API Key"]}}}}
```

## Create signed upload URL for prompt file

> Creates a signed URL that allows uploading a file that can later be attached to a prompt via the create prompt API (use returned storagePath in body.files).

```json
{"openapi":"3.0.0","info":{"title":"AI Agent API","version":"1.0.0"},"servers":[{"url":"https://api.raia2.com","description":"Production server"}],"security":[{"Agent-Secret-Key":[]}],"components":{"securitySchemes":{"Agent-Secret-Key":{"type":"apiKey","in":"header","name":"Agent-Secret-Key","description":"Custom authentication header"}},"schemas":{"CreatePromptFileSignedUploadUrlBodyDTO":{"type":"object","properties":{"fileName":{"type":"string","description":"File name"},"contentType":{"type":"string","description":"File content type"}},"required":["fileName","contentType"]},"CreatePromptFileSignedUploadUrlResponseDTO":{"type":"object","properties":{"signedUrl":{"type":"string","description":"Signed upload URL"},"storagePath":{"type":"string","description":"Storage path that should be sent later in send message API"}},"required":["signedUrl","storagePath"]},"ForbiddenErrorDTO":{"type":"object","properties":{"status":{"type":"number","default":403},"name":{"type":"object","default":"FORBIDDEN_ERROR"},"message":{"type":"string","default":"INVALID_CREDENTIALS"},"details":{"type":"array","items":{"type":"object"}}},"required":["status","name","message","details"]},"InternalServerErrorDTO":{"type":"object","properties":{"status":{"type":"number","default":500},"message":{"type":"string","default":"Internal Server Error"}},"required":["status","message"]}}},"paths":{"/external/prompts/upload-url":{"post":{"description":"Creates a signed URL that allows uploading a file that can later be attached to a prompt via the create prompt API (use returned storagePath in body.files).","operationId":"ExternalApiPromptsController_createPromptFileSignedUploadUrl","parameters":[],"requestBody":{"required":true,"description":"Provide fileName and contentType.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreatePromptFileSignedUploadUrlBodyDTO"}}}},"responses":{"200":{"description":"Successfully created signed upload URL.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreatePromptFileSignedUploadUrlResponseDTO"}}}},"403":{"description":"Invalid API key or secret key. Ensure that you are using a valid authentication key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ForbiddenErrorDTO"}}}},"429":{"description":"Rate limit exceeded. Each organization is limited to 1000 requests per 60 seconds for system external API operations."},"500":{"description":"Unexpected error occurred while processing the request. Please try again later.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalServerErrorDTO"}}}}},"summary":"Create signed upload URL for prompt file","tags":["Prompts","Agent API Key"]}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://raia2.gitbook.io/raia/api-reference/prompts.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
