Deployment API
Overview
This page explains how to use our deployment API with several use cases, providing detailed instructions and examples for different scenarios.
Run deployed models with chat completion
Executes a RAG-enhanced chat completion request against a deployed LLM application.
Endpoint
POST https://deployment.datasaur.ai/api/deployment/:teamId/:deploymentId/chat/completionsPath parameters
teamId
string
Your team identifier
deploymentId
string
The ID of your deployed model
Query parameters
source
string
(Optional) Source identifier
sourceId
string
(Optional) Specific source ID
Request body
The request body follows the OpenAI-compatible chat completion format, with additional RAG-specific enhancements.
Key properties
messages
array
Yes
Array of message objects representing the conversation
stream
boolean
No
Enable streaming responses
include_usage
boolean
No
rewrite_query
string
No
Override the behavior of summarizing the messages as query with an arbitrary text.
filter_metadata
object | string
No
Filter data based on the File Properties attached to each file.
Message types
Messages can be of the following roles:
user: User inputs.assistant: Assistant responses.tool: Tool/function responses.
Advanced features
Multimedia content types
The content field in messages supports various types:
Text content
Image Content
URL content
The URL content type supports both standard web URLs and base64-encoded data URLs, allowing you to:
Reference external web content: Use standard URLs (
https://example.com).Embed file content directly: Use base64 data URLs for PDF, HTML, or other content types.
Options:
select_pages: Specifies which pages to process from multi-page documents (PDFs)
Format:
1-5(range),1,3,5(specific pages), or1-3,7,9-11(combination).Example:
"select_pages": "1-3,5,8-10".Default: All pages if not specified.
include_page_screenshot_as_image: When set to true, includes visual representations of pages. The visual representations are also sent to the model when the model selected in the sandbox application supports visual capability.
For PDFs: Renders page as image for visual analysis.
For websites: Captures screenshot of the rendered page.
Enables the model to analyze visual layouts, charts, and non-text elements.
Default:
false.
Base64 encoding is particularly useful for:
Embedding content directly without requiring separate file uploads.
Processing temporary or dynamically generated content.
Working with content that doesn't have a public URL.
Advanced retrieval: Query rewriting
Query rewriting is a technique used in information retrieval and search systems to modify or enhance the original search query to improve search results. There might be cases where you prefer a customized way to summarize the message. You can rewrite the query with your version by specifying the rewrite_query. For example:
Advanced retrieval: Metadata filtering
Another way to improve the accuracy of the retrieval is through additional filtering, to ensure only relevant information is retrieved. Below is an example of filtering search result based on the jurisdiction and the date.
Example usage
Simple text query
Multi-turn conversation
Text with images
Text with PDF analysis
URL with Base64 screenshot
Metadata filtering
Response
Non-streaming response
Streaming response
Sends chunks of the response as Server-Sent Events (SSE) with the following format:
Error handling
The API uses standard HTTP status codes with specific actions for resolution:
400 Bad Request
Cause: Invalid parameters or malformed request.
Recommended resolution:
Check request body format and required fields.
Validate parameter types and values.
Ensure message array is not empty.
Check if URLs are properly formatted and accessible.
401 Unauthorized
Cause: Missing or invalid authentication.
Recommended resolution:
Check if API key is included in the request header.
Verify API key is valid and not expired.
Ensure API key has correct format.
Generate a new API key if necessary.
Contact support@datasaur.ai if API key should be valid.
403 Forbidden
Cause: Insufficient permissions for the requested operation.
Recommended resolution:
Verify team membership and permissions.
Check if you have access to the specified LLM application.
Ensure your subscription covers the requested features.
Request necessary permissions from team admin.
Upgrade subscription tier if needed.
429 Too Many Requests
Cause: Rate limit exceeded, see Rate Limiting section below for more details.
Recommended resolution:
Implement exponential backoff retry logic.
Check rate limits in response headers.
Reduce request frequency.
Consider upgrading your plan for higher limits.
Optimize batch operations to reduce API calls.
500 Internal Server Error
Cause: Server-side error.
Recommended resolution:
Retry request after a brief delay.
Check system status page for outages.
Verify request payload size is within limits.
Contact support@datasaur.ai if error persists.
Save error response for troubleshooting.
For all errors, the response will include a detailed error message to help diagnose the issue. If problems persist after taking the recommended actions, please contact support@datasaur.ai with the error details.
Rate limit
The API enforces the following rate limits. If any of these limits is reached, subsequent requests will be rejected with a 429 (Too Many Requests) status code until the limit resets:
Origin IP address-based: 1500 requests per 60 seconds.
Deployment ID-based: 300 requests per 60 seconds.
Team-based: Daily limits apply for free trial accounts.
Best practices
Set appropriate
temperaturevalues in the sandbox:Lower (0.2) for factual responses.
Higher (0.8) for creative responses.
Enable
stream: truefor real-time responses.Use
rewrite_queryfor optimized RAG queries.Include relevant file and URL content for context-aware responses.
Last updated