microsoft-foundry.rest.security.o-auth2-auth
Containers
Create a container file multipart Create a container file json
POST
/openai/v1/containers/{container_id}/files
Creates a container file multipart from the supplied request. Creates a container file json from the supplied request.
路徑參數
container_id
string
必要
The ID of the container.
要求本文
The multipart request body. The request body.
Content-Type: multipart/form-data
file_id
object
Name of the file to create.
file
object
The File object (not file name) to be uploaded.
Content-Type: application/json
file_id
object
Name of the file to create.
file
object
The File object (not file name) to be uploaded.
回覆
The request has succeeded.
主體
Content-Type: application/json
id
string
必要
Unique identifier for the file.
object
enum
必要
The type of this object (container.file).
container.file
container_id
string
必要
The container this file belongs to.
created_at
integer
必要
Unix timestamp (in seconds) when the file was created.
bytes
integer
必要
path
string
必要
Path of the file in the container.
source
string
必要
Source of the file (e.g., user, assistant).
Request
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)
回應
{
"id": "cfile_682e0e8a43c88191a7978f477a09bdf5",
"object": "container.file",
"created_at": 1747848842,
"bytes": 880,
"container_id": "cntr_682e0e7318108198aa783fd921ff305e08e78805b9fdbb04",
"path": "/mnt/data/88e12fa445d32636f190a0b33daed6cb-tsconfig.json",
"source": "user"
}