Pular para o conteúdo principal

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 & EndpointDescription
GET /api/filesList all files
POST /api/filesUpload a new file
GET /api/files/{file_id}File details
GET /api/files/{file_id}/contentDownload 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.


import openai

client = openai.OpenAI(
api_key="", # Your API_KEY
base_url="https://chat.maritaca.ai/api",
)

files = client.files.list()
print(files)

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.


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)

Retrieve file details​

Returns metadata for a file.

GET /api/files/{file_id}

Path Parameters​


file_id string Required ID returned on upload or listing.


metadata = client.files.retrieve("file-1")
print(metadata)

Download file content​

Returns the raw content of a file.

GET /api/files/{file_id}/content

Path Parameters​


file_id string Required


content = client.files.retrieve_content("file-1")
with open("download.jsonl", "wb") as f:
f.write(content)

Delete a file​

Deletes a file.

DELETE /api/files/{file_id}

Path Parameters​


file_id string Required


client.files.delete("batch_input.jsonl")

Batch Inference /api/batches​

Method & EndpointDescription
GET /api/batchesList all batches
POST /api/batchesCreate a new batch
GET /api/batches/{batch_id}Batch details
POST /api/batches/{batch_id}/cancelCancel 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"}).


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)

List batches​

GET /api/batches

Query Parameters​


limit integer Optional Maximum items per page.

after string Optional Cursor for the next page.


batches = client.beta.batches.list(limit=10)
for b in batches.data:
print(b.id, b.status)

Retrieve a batch​

GET /api/batches/{batch_id}

Path Parameters​


batch_id string Required


batch = client.beta.batches.retrieve("batch-1")
print(batch)

Cancel a batch​

POST /api/batches/{batch_id}/cancel

Path Parameters​


batch_id string Required


cancelled = client.beta.batches.cancel("batch-1")
print(cancelled.status)