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.
Parâmetros de caminho
container_id
string
exigido
The ID of the container.
Corpo da solicitação
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.
Respostas
The request has succeeded.
Corpo
id
string
exigido
Unique identifier for the file.
object
enum
exigido
The type of this object (container.file).
container_id
string
exigido
The container this file belongs to.
created_at
integer
exigido
Unix timestamp (in seconds) when the file was created.
path
string
exigido
Path of the file in the container.
source
string
exigido
Source of the file (e.g., user, assistant).
Solicitar
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)
Resposta
{
"id": "cfile_682e0e8a43c88191a7978f477a09bdf5",
"object": "container.file",
"created_at": 1747848842,
"bytes": 880,
"container_id": "cntr_682e0e7318108198aa783fd921ff305e08e78805b9fdbb04",
"path": "/mnt/data/88e12fa445d32636f190a0b33daed6cb-tsconfig.json",
"source": "user"
}