microsoft-foundry.rest.security.o-auth2-auth
Files
Download a file
GET
/openai/v1/files/{file_id}/content
Downloads a file.
Path parameters
file_id
string
required
The ID of the file to use for this request.
Responses
The request has succeeded.
Body
Content-Type: text/plain
string
Request
curl https://api.openai.com/v1/files/file-abc123/content \
-H "Authorization: Bearer $OPENAI_API_KEY" > file.jsonl
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
)
response = client.files.content(
"file_id",
)
print(response)
content = response.read()
print(content)
import OpenAI from "openai";
const openai = new OpenAI();
async function main() {
const file = await openai.files.content("file-abc123");
console.log(file);
}
main();
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});
const response = await client.files.content('file_id');
console.log(response);
const content = await response.blob();
console.log(content);
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"),
)
response, err := client.Files.Content(context.TODO(), "file_id")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v
", response)
}
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.core.http.HttpResponse;
import com.openai.models.files.FileContentParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
HttpResponse response = client.files().content("file_id");
}
}
require "openai"
openai = OpenAI::Client.new(api_key: "My API Key")
response = openai.files.content("file_id")
puts(response)