AIDevKit - AI Suite for Unity
API ReferencesDiscordGlitch9
  • Introduction
    • AI Dev Kit 3.7.0
    • Troubleshooting
    • FAQ
    • Update Logs
  • Provider Setup
    • OpenAI
    • Google Gemini
    • ElevenLabs
    • Ollama
    • OpenRouter
  • Editor Tools
    • Introduction
    • Editor Chat
    • Model Library
    • Voice Library
  • GEN Tasks
    • Prefixes
    • Response
    • Chat
    • Image
    • Video
    • SoundFX
    • Speech
    • Transcript
    • Voice Change
    • Audio Isolation
  • Advanced API (Pro)
    • Assistants
      • How it works
      • Creating custom functions
      • Creating assistants API
    • Realtime
  • Legacy API
    • OpenAI
      • 💬Chat completions
      • 🖼️Image operations
      • 🗣️Text to speech
      • 🎙️Speech to text
        • Recording real-time in Unity
      • 💾Files
      • 🔎Embeddings
      • 🛡️Moderations
      • ⚙️Fine-tuning
    • Google Gemini
      • 📝System instructions
      • 💬Text generation
      • ⚙️Fine-tuning
      • ▶️Fucntion calling
      • 🔎Embeddings
      • 🛡️Safety
      • 💻Code execution
  • Legacy Documents
    • AI Dev Kit 1.0
      • Preperation
      • Scriptable Toolkits
        • Chat Streamer
        • Image Generator
        • Voice Transcriber
        • Voice Generator
      • Editor Tools
      • Troubleshooting (Legacy)
        • ❗Build Error: The name 'UnityMenu' does not exist in the current context
        • ❗The type or namespace name 'AndroidJavaObject' could not be found
        • ❗The type or namaspace name 'Plastic' does not exist
        • ❗Build Error: The name 'Asset Database' does not exist in the current context
        • ❗'ModelData.Create(Provider, string, UnixTime?, string)': not all code paths return a value
      • Code Generators
        • C# Script Generator
        • Unity Component Generator
    • AI Dev Kit 2.0
      • Event Handlers
      • Editor Chat
      • Editor Vision (TTI, ITI)
      • Editor Speech (TTS)
      • Management Tools
        • Prompt History Viewer
        • AI Model Manager
        • TTS Voice Manager
        • OpenAI File Manager
        • OpenAI Assistant Manager
        • ElevenLabs Voice Library
Powered by GitBook
On this page
  • Upload file
  • List files
  • Retrieve file
  • Delete file
  • Retrieve file content
  1. Legacy API
  2. OpenAI

Files

Files are used to upload documents that can be used with features like Assistants, Fine-tuning, and Batch API.

PreviousRecording real-time in UnityNextEmbeddings

Last updated 10 months ago

Upload a file that can be used across various endpoints. Individual files can be up to 512 MB, and the size of all files uploaded by one organization can be up to 100 GB.

  • Supports files up to 2 million tokens and of specific file types.

  • See the for details.

  • Only supports .jsonl file.

  • The input also has certain required formats for fine-tuning or models.

  • Only supports .jsonl file.

  • Up to 100 MB in size.

  • The input also has a specific required .

var file = new FormFile("path/to/mydata.jsonl");

var request = new FileUploadRequest.Builder()
    .SetFile(file)
    .SetPurpose(UploadPurpose.FineTune)
    .Build();

var result = await OpenAI.DefaultInstance.Files.Upload(request);

Debug.Log(result.Id);
from openai import OpenAI
client = OpenAI()

client.files.create(
  file=open("mydata.jsonl", "rb"),
  purpose="fine-tune"
)

Please if you need to increase these storage limits.


Returns a list of files that belong to the user's organization.

var fileList = await OpenAI.DefaultInstance.Files.List();

foreach (var fileData in fileList)
{
    Debug.Log(fileData.Id);
    Debug.Log(fileData.CreatedAt);
    Debug.Log(fileData.Purpose);
}
from openai import OpenAI
client = OpenAI()

client.files.list()

Returns information about a specific file.

var fileData = await OpenAI.DefaultInstance.Files.Retrieve("file-abc123");

Debug.Log(fileData.Id);
from openai import OpenAI
client = OpenAI()

client.files.retrieve("file-abc123")

Delete a file.

bool deleted = await OpenAI.DefaultInstance.Files.Delete("file-abc123");

if (deleted)
{
    Debug.Log("File deleted successfully");
}
from openai import OpenAI
client = OpenAI()

client.files.delete("file-abc123")

Returns the contents of the specified file.

var content = await OpenAI.DefaultInstance.Files.RetrieveFileContent("file-abc123");

Debug.Log(content);
from openai import OpenAI
client = OpenAI()

content = client.files.content("file-abc123")

💾
Upload file
Assistants Tools guide
chat
completions
format
contact OpenAI
List files
Retrieve file
Delete file
Retrieve file content