Files
herolib/lib/clients/openai/files
2025-10-12 12:30:19 +03:00
..
...
2025-08-06 08:50:32 +02:00

Example: Uploading a File

import incubaid.herolib.clients.openai

mut client:= openai.get()! //will be the default client, key is in `AIKEY` on environment variable or `OPENROUTER_API_KEY`

// Assuming you have a file named 'mydata.jsonl' in the same directory
// For a real application, handle file paths dynamically
file_path := 'mydata.jsonl'

resp := client.files.upload_file(
    file: file_path,
    purpose: 'fine-tune' // or 'assistants', 'batch', 'vision'
)

if resp.id.len > 0 {
    println('File uploaded successfully with ID: ${resp.id}')
} else {
    eprintln('Failed to upload file.')
}