Skip to content
For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to the page URL.
Primary navigation

Retrieve file

client.Files.Get(ctx, fileID) (*FileObject, error)
GET/files/{file_id}

Returns information about a specific file.

ParametersExpand Collapse
fileID string
ReturnsExpand Collapse
type FileObject struct{…}

The File object represents a document that has been uploaded to OpenAI.

ID string

The file identifier, which can be referenced in the API endpoints.

Bytes int64

The size of the file, in bytes. In a completed file upload response, this can be null when the file size is not yet available.

CreatedAt int64

The Unix timestamp (in seconds) for when the file was created.

formatunixtime
Filename string

The name of the file.

Object File

The object type, which is always file.

Purpose FileObjectPurpose

The intended purpose of the file. Supported values are assistants, assistants_output, batch, batch_output, fine-tune, fine-tune-results, vision, and user_data.

Status FileObjectStatus

Deprecated.

Deprecated. The current status of the file, which can be either uploaded, processed, or error.

ExpiresAt int64Optional

The Unix timestamp (in seconds) for when the file will expire. In a completed file upload response, this can be null when no expiry is set.

formatunixtime
StatusDetails stringOptional

Deprecated.

Deprecated. For details on why a fine-tuning training file failed validation, see the error field on fine_tuning.job. Completed file upload responses can return null when these details are unset.

Retrieve file

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"),
  )
  fileObject, err := client.Files.Get(context.TODO(), "file_id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", fileObject.ID)
}
{
  "id": "file-abc123",
  "object": "file",
  "bytes": 120000,
  "created_at": 1677610602,
  "expires_at": 1680202602,
  "filename": "mydata.jsonl",
  "purpose": "fine-tune",
  "status": "processed"
}
Returns Examples
{
  "id": "file-abc123",
  "object": "file",
  "bytes": 120000,
  "created_at": 1677610602,
  "expires_at": 1680202602,
  "filename": "mydata.jsonl",
  "purpose": "fine-tune",
  "status": "processed"
}