microsoft-foundry.rest.security.o-auth2-auth
Uploads
Add an upload part
POST
/openai/v1/uploads/{upload_id}/parts
Adds an upload part to the parent resource.
경로 매개 변수
upload_id
string
필수
The ID of the Upload.
요청 본문
The multipart request body.
Content-Type: multipart/form-data
data
OpenAI.AddUploadPartRequest
필수
The chunk of bytes for this Part.
응답
The request has succeeded.
본문
Content-Type: application/json
id
string
필수
The upload Part unique identifier, which can be referenced in API endpoints.
created_at
integer
필수
The Unix timestamp (in seconds) for when the Part was created.
upload_id
string
필수
The ID of the Upload object that this Part was added to.
object
enum
필수
The object type, which is always upload.part.
upload.part
요청
curl https://api.openai.com/v1/uploads/upload_abc123/parts
-F data="aHR0cHM6Ly9hcGkub3BlbmFpLmNvbS92MS91cGxvYWRz..."
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 uploadPart = await client.uploads.parts.create('upload_abc123', {
data: fs.createReadStream('path/to/file'),
});
console.log(uploadPart.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
)
upload_part = client.uploads.parts.create(
upload_id="upload_abc123",
data=b"Example data",
)
print(upload_part.id)
package main
import (
"bytes"
"context"
"fmt"
"io"
"github.com/openai/openai-go"
"github.com/openai/openai-go/option"
)
func main() {
client := openai.NewClient(
option.WithAPIKey("My API Key"),
)
uploadPart, err := client.Uploads.Parts.New(
context.TODO(),
"upload_abc123",
openai.UploadPartNewParams{
Data: io.Reader(bytes.NewBuffer([]byte("Example data"))),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v
", uploadPart.ID)
}
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.uploads.parts.PartCreateParams;
import com.openai.models.uploads.parts.UploadPart;
import java.io.ByteArrayInputStream;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
PartCreateParams params = PartCreateParams.builder()
.uploadId("upload_abc123")
.data(new ByteArrayInputStream("Example data".getBytes()))
.build();
UploadPart uploadPart = client.uploads().parts().create(params);
}
}
require "openai"
openai = OpenAI::Client.new(api_key: "My API Key")
upload_part = openai.uploads.parts.create("upload_abc123", data: StringIO.new("Example data"))
puts(upload_part)
응답
{
"id": "part_def456",
"object": "upload.part",
"created_at": 1719185911,
"upload_id": "upload_abc123"
}