Overview
Maritaca’s Batch API provides operations for:
- Files – store or retrieve files used in requests.
- Batch inference – run asynchronous jobs in bulk.
Base URL:
https://chat.maritaca.ai
Files /api/files
| Method & Endpoint | Description |
|---|---|
GET /api/files | List all files |
POST /api/files | Upload a new file |
GET /api/files/{file_id} | File details |
GET /api/files/{file_id}/content | Download file content |
DELETE /api/files/{file_id} | Delete a file |
List files
Lists previously uploaded files.
GET /api/files
Query Parameters
limit integer Optional
Maximum items per page.
after string Optional
Cursor for the next page (value of next_cursor from the previous response).
purpose string Optional
Filter files by purpose (batch_input).
order string Optional
Sort order.
- Default
- Direct API Call
import openai
client = openai.OpenAI(
api_key="", # Your API_KEY
base_url="https://chat.maritaca.ai/api",
)
files = client.files.list()
print(files)
import requests
url = "https://chat.maritaca.ai/api/files"
headers = {"Authorization": f"Key {api_key}"}
response = requests.get(url, headers=headers)
print(response.json())
Upload file
Uploads the file containing the requests.
POST /api/files
Request Body
file file Required
The binary file to upload (.jsonl, .csv, .txt, etc.).
purpose string Required
Defines the intended use of the file — currently only batch_input is accepted.
- Default
- Direct API Call
import openai
client = openai.OpenAI(
api_key="", # Your API_KEY
base_url="https://chat.maritaca.ai/api",
)
batch_input_file = client.files.create(
file=open("batch_input.jsonl", "rb"),
purpose="batch_input"
)
print(batch_input_file)
import requests
url = "https://chat.maritaca.ai/api/files"
headers = {"Authorization": f"Key {api_key}"}
files = {"file": ("batch_input.jsonl", open("batch_input.jsonl", "rb"))}
data = {"purpose": "batch_input"}
resp = requests.post(url, headers=headers, files=files, data=data)
print(resp.json())
Retrieve file details
Returns metadata for a file.
GET /api/files/{file_id}
- Default
- Direct API Call
metadata = client.files.retrieve("file-1")
print(metadata)
import requests
file_id = "file-1"
url = f"https://chat.maritaca.ai/api/files/{file_id}"
headers = {"Authorization": f"Key {api_key}"}
resp = requests.get(url, headers=headers)
print(resp.json())
Download file content
Returns the raw content of a file.
GET /api/files/{file_id}/content
- Default
- Direct API Call
content = client.files.retrieve_content("file-1")
with open("download.jsonl", "wb") as f:
f.write(content)
import requests
file_id = "file-1"
url = f"https://chat.maritaca.ai/api/files/{file_id}/content"
headers = {"Authorization": f"Key {api_key}"}
with requests.get(url, headers=headers, stream=True) as r:
r.raise_for_status()
with open("download.jsonl", "wb") as f:
for chunk in r.iter_content(chunk_size=8192):
f.write(chunk)
Delete a file
Deletes a file.
DELETE /api/files/{file_id}
- Default
- Direct API Call
client.files.delete("batch_input.jsonl")
import requests
file_id = "batch_input.jsonl"
url = f"https://chat.maritaca.ai/api/files/{file_id}"
headers = {"Authorization": f"Key {api_key}"}
resp = requests.delete(url, headers=headers)
print(resp.status_code) # 200 = success
Batch Inference /api/batches
| Method & Endpoint | Description |
|---|---|
GET /api/batches | List all batches |
POST /api/batches | Create a new batch |
GET /api/batches/{batch_id} | Batch details |
POST /api/batches/{batch_id}/cancel | Cancel a running batch |
Create batch
Creates a job from a previously uploaded file.
POST /api/batches
Request Body
input_file_id string Required
ID of the .jsonl file with input lines.
endpoint string Required
Destination route, e.g. /chat/completions.
completion_window string Optional
Maximum execution time (24h, 1h).
metadata object Optional
Any key-value pairs (e.g. {"project": "demo"}).
- Default
- Direct API Call
batch = client.beta.batches.create(
input_file_id="file-1",
endpoint="/v1/chat/completions",
completion_window="24h",
metadata={
"description": "job for marketing data",
"owner": "marketing team"
}
)
print(batch.id)
import requests, json
url = "https://chat.maritaca.ai/api/batches"
headers = {
"Authorization": f"Key {api_key}",
"Content-Type": "application/json"
}
payload = {
"input_file_id": "file-1",
"endpoint": "/v1/chat/completions",
"completion_window": "24h",
"metadata": {
"description": "job for marketing data",
"owner": "marketing team"
}
}
resp = requests.post(url, headers=headers, json=payload)
print(resp.json())
List batches
GET /api/batches
Query Parameters
limit integer Optional
Maximum items per page.
after string Optional
Cursor for the next page.
- Default
- Direct API Call
batches = client.beta.batches.list(limit=10)
for b in batches.data:
print(b.id, b.status)
import requests
url = "https://chat.maritaca.ai/api/batches"
params = {"limit": 10}
headers = {"Authorization": f"Key {api_key}"}
resp = requests.get(url, headers=headers, params=params)
print(resp.json())
Retrieve a batch
GET /api/batches/{batch_id}
- Default
- Direct API Call
batch = client.beta.batches.retrieve("batch-1")
print(batch)
import requests
batch_id = "batch-1"
url = f"https://chat.maritaca.ai/api/batches/{batch_id}"
headers = {"Authorization": f"Key {api_key}"}
resp = requests.get(url, headers=headers)
print(resp.json())
Cancel a batch
POST /api/batches/{batch_id}/cancel
- Default
- Direct API Call
cancelled = client.beta.batches.cancel("batch-1")
print(cancelled.status)
import requests
batch_id = "batch-1"
url = f"https://chat.maritaca.ai/api/batches/{batch_id}/cancel"
headers = {"Authorization": f"Key {api_key}"}
resp = requests.post(url, headers=headers)
print(resp.json())