Containers
Create a container file multipart Create a container file json
Creates a container file multipart from the supplied request. Creates a container file json from the supplied request.
Pfadparameter
container_id
string
Erforderlich
The ID of the container.
Anforderungstext
The multipart request body. The request body.
file_id
object
Name of the file to create.
file
object
The File object (not file name) to be uploaded.
file_id
object
Name of the file to create.
file
object
The File object (not file name) to be uploaded.
Antworten
The request has succeeded.
Text
id
string
Erforderlich
Unique identifier for the file.
object
enum
Erforderlich
The type of this object (container.file).
container_id
string
Erforderlich
The container this file belongs to.
created_at
integer
Erforderlich
Unix timestamp (in seconds) when the file was created.
path
string
Erforderlich
Path of the file in the container.
source
string
Erforderlich
Source of the file (e.g., user, assistant).
Anfordern
curl https://api.openai.com/v1/containers/cntr_682e0e7318108198aa783fd921ff305e08e78805b9fdbb04/files \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-F file="@example.txt"
import fs from 'fs';
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});
const file = await client.containers.files.create('container_id');
console.log(file.id);
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
)
file = client.containers.files.create(
container_id="container_id",
)
print(file.id)
package main
import (
"context"
"fmt"
"github.com/openai/openai-go"
"github.com/openai/openai-go/option"
)
func main() {
client := openai.NewClient(
option.WithAPIKey("My API Key"),
)
file, err := client.Containers.Files.New(
context.TODO(),
"container_id",
openai.ContainerFileNewParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v
", file.ID)
}
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.containers.files.FileCreateParams;
import com.openai.models.containers.files.FileCreateResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
FileCreateResponse file = client.containers().files().create("container_id");
}
}
require "openai"
openai = OpenAI::Client.new(api_key: "My API Key")
file = openai.containers.files.create("container_id")
puts(file)
Antwort
{
"id": "cfile_682e0e8a43c88191a7978f477a09bdf5",
"object": "container.file",
"created_at": 1747848842,
"bytes": 880,
"container_id": "cntr_682e0e7318108198aa783fd921ff305e08e78805b9fdbb04",
"path": "/mnt/data/88e12fa445d32636f190a0b33daed6cb-tsconfig.json",
"source": "user"
}