Skip to content

Files & Batches

Upload, retrieve, list, and delete files. Files are used with batch processing, fine-tuning, and assistants.

Upload a file for use with the API

Python
import asyncio
import os
from liter_llm import create_client
from liter_llm._internal_bindings import CreateFileRequest
async def main() -> None:
client = create_client(api_key=os.environ["API_KEY"])
req = CreateFileRequest.from_json("{\"file\":\"eyJwcm9tcHQiOiAiaGVsbG8ifQo=\",\"filename\":\"training_data.jsonl\",\"purpose\":\"fine-tune\"}")
result = await client.create_file(req)
print(result.id)
asyncio.run(main())
Method Description
create_file Upload a file with a purpose ("batch", "fine-tune", "assistants")
retrieve_file Get metadata for an uploaded file by ID
delete_file Delete an uploaded file by ID
list_files List all uploaded files, optionally filtered by purpose
file_content Download the raw content of an uploaded file

Create batch jobs to process multiple requests asynchronously at reduced cost:

Create a new batch processing job

Python
import asyncio
import os
from liter_llm import create_client
from liter_llm._internal_bindings import CreateBatchRequest
async def main() -> None:
client = create_client(api_key=os.environ["API_KEY"])
req = CreateBatchRequest.from_json("{\"completion_window\":\"24h\",\"endpoint\":\"/v1/chat/completions\",\"input_file_id\":\"file-abc123\"}")
result = await client.create_batch(req)
print(result.id)
print(result.status)
asyncio.run(main())
Method Description
create_batch Create a batch from an uploaded JSONL file
retrieve_batch Get batch status and results by ID
list_batches List all batches
cancel_batch Cancel a running batch
Parameter Type Description
input_file_id string ID of the uploaded JSONL file
endpoint string API endpoint ("/v1/chat/completions", "/v1/embeddings")
completion_window string Processing window ("24h")
metadata object Optional key-value metadata

Create, retrieve, and cancel responses via the Responses API:

Create a basic response using the Responses API

Python
import asyncio
import os
from liter_llm import create_client
from liter_llm._internal_bindings import CreateResponseRequest
async def main() -> None:
client = create_client(api_key=os.environ["API_KEY"])
req = CreateResponseRequest.from_json("{\"input\":\"Explain quantum computing in one sentence.\",\"model\":\"gpt-4o\"}")
result = await client.create_response(req)
print(result.id)
print(result.status)
print(result.output)
asyncio.run(main())
Method Description
create_response Create a new response
retrieve_response Get a response by ID
cancel_response Cancel a response
Parameter Type Description
model string Model to use
input string Input text or conversation
instructions string System-level instructions
max_output_tokens int Maximum tokens to generate
temperature float Sampling temperature