client

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2025 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SafeJoinURL

func SafeJoinURL(baseURL, path string) string

SafeJoinURL safely joins a base URL with a path

Types

type APIKey

type APIKey struct {
	ID         string `json:"id"`
	Name       string `json:"name"`
	CreatedAt  *int64 `json:"created_at"`
	LastUsedAt *int64 `json:"last_used_at,omitempty"`
}

APIKey represents an API key in OpenAI

type AddProjectUserRequest

type AddProjectUserRequest struct {
	UserID string `json:"user_id"`
	Role   string `json:"role"`
}

AddProjectUserRequest represents the request to add a user to a project

type AdminAPIKey

type AdminAPIKey struct {
	ID         string   `json:"id"`
	Name       string   `json:"name"`
	CreatedAt  int64    `json:"created_at"`
	ExpiresAt  *int64   `json:"expires_at,omitempty"`
	LastUsedAt *int64   `json:"last_used_at,omitempty"`
	Scopes     []string `json:"scopes"`
	Object     string   `json:"object"`
}

AdminAPIKey represents an API key in the OpenAI admin context

type AdminAPIKeyResponse

type AdminAPIKeyResponse struct {
	ID        string   `json:"id"`
	Name      string   `json:"name"`
	CreatedAt int64    `json:"created_at"`
	ExpiresAt *int64   `json:"expires_at,omitempty"`
	Object    string   `json:"object"`
	Scopes    []string `json:"scopes"`
	Key       string   `json:"key"`
}

AdminAPIKeyResponse represents the API response when creating an API key

type AssistantFunction

type AssistantFunction struct {
	Name        string          `json:"name"`
	Description string          `json:"description"`
	Parameters  json.RawMessage `json:"parameters"`
}

AssistantFunction represents a function configuration for an assistant tool.

type AssistantResponse

type AssistantResponse struct {
	ID           string                 `json:"id"`
	Object       string                 `json:"object"`
	CreatedAt    int                    `json:"created_at"`
	Name         string                 `json:"name"`
	Description  string                 `json:"description"`
	Model        string                 `json:"model"`
	Instructions string                 `json:"instructions"`
	Tools        []AssistantTool        `json:"tools"`
	FileIDs      []string               `json:"file_ids"`
	Metadata     map[string]interface{} `json:"metadata"`
}

AssistantResponse represents an individual assistant in the API response.

type AssistantTool

type AssistantTool struct {
	Type     string             `json:"type"`
	Function *AssistantFunction `json:"function,omitempty"`
}

AssistantTool represents a tool configuration for an assistant.

type ChatCompletionChoice

type ChatCompletionChoice struct {
	Index        int                   `json:"index"`         // Index of the choice in the list
	Message      ChatCompletionMessage `json:"message"`       // The generated message
	FinishReason string                `json:"finish_reason"` // Reason why the completion finished
}

ChatCompletionChoice represents a single completion option from the model

type ChatCompletionMessage

type ChatCompletionMessage struct {
	Role         string            `json:"role"`                    // Role of the message sender (system, user, assistant)
	Content      string            `json:"content"`                 // Content of the message
	FunctionCall *ChatFunctionCall `json:"function_call,omitempty"` // Optional function call
	Name         string            `json:"name,omitempty"`          // Optional name of the message sender
}

ChatCompletionMessage represents a message in the chat completion

type ChatCompletionRequest

type ChatCompletionRequest struct {
	Model            string                  `json:"model"`                       // ID of the model to use
	Messages         []ChatCompletionMessage `json:"messages"`                    // List of messages in the conversation
	Functions        []ChatFunction          `json:"functions,omitempty"`         // Optional list of available functions
	FunctionCall     interface{}             `json:"function_call,omitempty"`     // Optional function call configuration
	Temperature      float64                 `json:"temperature,omitempty"`       // Sampling temperature
	TopP             float64                 `json:"top_p,omitempty"`             // Nucleus sampling parameter
	N                int                     `json:"n,omitempty"`                 // Number of completions to generate
	Stream           bool                    `json:"stream,omitempty"`            // Whether to stream the response
	Stop             []string                `json:"stop,omitempty"`              // Optional stop sequences
	MaxTokens        int                     `json:"max_tokens,omitempty"`        // Maximum tokens to generate
	PresencePenalty  float64                 `json:"presence_penalty,omitempty"`  // Presence penalty parameter
	FrequencyPenalty float64                 `json:"frequency_penalty,omitempty"` // Frequency penalty parameter
	LogitBias        map[string]float64      `json:"logit_bias,omitempty"`        // Optional token bias
	User             string                  `json:"user,omitempty"`              // Optional user identifier
}

ChatCompletionRequest represents a request to the chat completion API

type ChatCompletionResponse

type ChatCompletionResponse struct {
	ID      string                 `json:"id"`      // Unique identifier for the completion
	Object  string                 `json:"object"`  // Type of object (e.g., "chat.completion")
	Created int                    `json:"created"` // Unix timestamp when the completion was created
	Model   string                 `json:"model"`   // Model used for the completion
	Choices []ChatCompletionChoice `json:"choices"` // List of possible completions
	Usage   ChatCompletionUsage    `json:"usage"`   // Token usage statistics
}

ChatCompletionResponse represents the API response for chat completions

type ChatCompletionUsage

type ChatCompletionUsage struct {
	PromptTokens     int `json:"prompt_tokens"`     // Number of tokens in the prompt
	CompletionTokens int `json:"completion_tokens"` // Number of tokens in the completion
	TotalTokens      int `json:"total_tokens"`      // Total number of tokens used
}

ChatCompletionUsage represents token usage statistics for the completion request

type ChatFunction

type ChatFunction struct {
	Name        string          `json:"name"`                  // Name of the function
	Description string          `json:"description,omitempty"` // Optional function description
	Parameters  json.RawMessage `json:"parameters"`            // JSON schema for function parameters
}

ChatFunction represents a function that can be called by the model

type ChatFunctionCall

type ChatFunctionCall struct {
	Name      string `json:"name"`      // Name of the function to call
	Arguments string `json:"arguments"` // JSON string containing function arguments
}

ChatFunctionCall represents a function call generated by the model

type ChunkingStrategy

type ChunkingStrategy struct {
	Type      string `json:"type"`
	Size      *int64 `json:"size,omitempty"`
	MaxTokens *int64 `json:"max_tokens,omitempty"`
}

ChunkingStrategy represents the chunking strategy for files in a vector store

type ClientConfig added in v1.1.0

type ClientConfig struct {
	APIKey         string
	OrganizationID string
	APIURL         string
	Timeout        time.Duration // Timeout for all operations
}

ClientConfig contains configuration options for the OpenAI client

type CreateAPIKeyRequest

type CreateAPIKeyRequest struct {
	Name      string   `json:"name"`
	ExpiresAt *int64   `json:"expires_at,omitempty"`
	Scopes    []string `json:"scopes,omitempty"`
}

CreateAPIKeyRequest represents the request to create an API key

type CreateProjectRequest

type CreateProjectRequest struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	IsDefault   bool   `json:"is_default,omitempty"`
}

CreateProjectRequest represents the request to create a project

type CreateProjectServiceAccountRequest

type CreateProjectServiceAccountRequest struct {
	Name string `json:"name"`
}

CreateProjectServiceAccountRequest represents the request to create a service account

type CreateRateLimitRequest

type CreateRateLimitRequest struct {
	ResourceType string `json:"resource_type"` // "request" or "token"
	LimitType    string `json:"limit_type"`    // "rpm" or "tpm"
	Value        int    `json:"value"`         // The limit value
}

CreateRateLimitRequest represents the request to create a rate limit

type Error

type Error struct {
	Message string `json:"message"`
	Type    string `json:"type"`
	Code    string `json:"code"`
}

Error represents an error from the OpenAI API

type ErrorResponse

type ErrorResponse struct {
	Error struct {
		Message string `json:"message"`
		Type    string `json:"type"`
		Param   string `json:"param"`
		Code    string `json:"code"`
	} `json:"error"`
}

ErrorResponse represents an error response from the OpenAI API

type ExpiresAfter

type ExpiresAfter struct {
	Days  *int64 `json:"days,omitempty"`
	Never *bool  `json:"never,omitempty"`
}

ExpiresAfter represents the expiration policy for a vector store

type Invite

type Invite struct {
	ID        string          `json:"id"`
	Object    string          `json:"object"`
	Email     string          `json:"email"`
	Role      string          `json:"role"`
	Status    string          `json:"status"`
	ExpiresAt int64           `json:"expires_at"`
	CreatedAt int64           `json:"created_at"`
	Projects  []InviteProject `json:"projects,omitempty"`
}

Invite represents an invitation to an OpenAI organization

type InviteProject

type InviteProject struct {
	ID   string `json:"id"`
	Role string `json:"role"`
}

InviteProject represents a project assignment for an invited user

type InviteRequest

type InviteRequest struct {
	Email    string          `json:"email"`
	Role     string          `json:"role"`
	Projects []InviteProject `json:"projects,omitempty"`
}

InviteRequest represents the request to invite a user to the organization

type InviteResponse

type InviteResponse struct {
	ID        string          `json:"id"`
	Object    string          `json:"object"`
	Email     string          `json:"email"`
	Role      string          `json:"role"`
	Status    string          `json:"status"`
	ExpiresAt int64           `json:"expires_at"`
	CreatedAt int64           `json:"created_at"`
	Projects  []InviteProject `json:"projects,omitempty"`
}

InviteResponse represents the API response when creating an invite

type ListAPIKeysResponse

type ListAPIKeysResponse struct {
	Object  string        `json:"object"`
	Data    []AdminAPIKey `json:"data"`
	HasMore bool          `json:"has_more"`
}

ListAPIKeysResponse represents the API response when listing API keys

type ListInvitesResponse

type ListInvitesResponse struct {
	Object  string   `json:"object"`
	Data    []Invite `json:"data"`
	HasMore bool     `json:"has_more"`
}

ListInvitesResponse represents the API response when listing invites

type ListProjectsResponse

type ListProjectsResponse struct {
	Object  string    `json:"object"`
	Data    []Project `json:"data"`
	HasMore bool      `json:"has_more"`
}

ListProjectsResponse represents the response from the API when listing projects

type ModelResponse

type ModelResponse struct {
	ID        string                     `json:"id"`
	Object    string                     `json:"object"`
	CreatedAt int                        `json:"created"`
	Model     string                     `json:"model"`
	Choices   []ModelResponseChoice      `json:"choices"`
	Usage     ModelResponseTokenUsage    `json:"usage"`
	System    ModelResponseSystemDetails `json:"system,omitempty"`
}

ModelResponse represents a response from the OpenAI model API

type ModelResponseChoice

type ModelResponseChoice struct {
	Index        int                        `json:"index"`
	Message      ModelResponseOutputMessage `json:"message"`
	FinishReason ModelResponseFinishReason  `json:"finish_reason"`
}

ModelResponseChoice represents a choice in the model response

type ModelResponseFinishReason

type ModelResponseFinishReason string

ModelResponseFinishReason string representation of finish reason

type ModelResponseOutputContent

type ModelResponseOutputContent struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

ModelResponseOutputContent represents the content part of a message

type ModelResponseOutputMessage

type ModelResponseOutputMessage struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

ModelResponseOutputMessage represents a message in the model response

type ModelResponseRequest

type ModelResponseRequest struct {
	Model       string   `json:"model"`
	Input       string   `json:"input"`
	MaxTokens   int      `json:"max_output_tokens,omitempty"`
	Temperature float64  `json:"temperature,omitempty"`
	TopP        float64  `json:"top_p,omitempty"`
	TopK        int      `json:"top_k,omitempty"`
	Stop        []string `json:"stop,omitempty"`
	User        string   `json:"user,omitempty"`
}

ModelResponseRequest represents a request to create a model response

type ModelResponseSystemDetails

type ModelResponseSystemDetails struct {
	Version string `json:"version"`
}

ModelResponseSystemDetails contains system details

type ModelResponseTokenUsage

type ModelResponseTokenUsage struct {
	PromptTokens     int `json:"prompt_tokens"`
	CompletionTokens int `json:"completion_tokens"`
	TotalTokens      int `json:"total_tokens"`
	InputTokens      int `json:"input_tokens,omitempty"`  // Alternative naming in some API versions
	OutputTokens     int `json:"output_tokens,omitempty"` // Alternative naming in some API versions
}

ModelResponseTokenUsage represents token usage in a model response

type OpenAIClient

type OpenAIClient struct {
	APIKey         string
	OrganizationID string
	APIURL         string
	HTTPClient     *http.Client
	Timeout        time.Duration // Timeout for all requests
}

OpenAIClient is a client for interacting with the OpenAI API

func NewClient

func NewClient(apiKey, organizationID, apiURL string) *OpenAIClient

NewClient creates a new instance of the OpenAI client

func NewClientWithConfig added in v1.1.0

func NewClientWithConfig(config ClientConfig) *OpenAIClient

NewClientWithConfig creates a new instance of the OpenAI client with custom configuration

func (*OpenAIClient) AddFileBatchToVectorStore

func (c *OpenAIClient) AddFileBatchToVectorStore(ctx context.Context, params *VectorStoreFileBatchCreateParams) (*VectorStoreFileBatch, error)

AddFileBatchToVectorStore adds a batch of files to a vector store

func (*OpenAIClient) AddFileToVectorStore

func (c *OpenAIClient) AddFileToVectorStore(ctx context.Context, params *VectorStoreFileCreateParams) (*VectorStoreFile, error)

AddFileToVectorStore adds a file to a vector store

func (*OpenAIClient) AddProjectUser

func (c *OpenAIClient) AddProjectUser(projectID, userID, role string) (*ProjectUser, error)

AddProjectUser adds a user to a project. Users must already be members of the organization to be added to a project.

Parameters:

  • projectID: The ID of the project to add the user to
  • userID: The ID of the user to add
  • role: The role to assign to the user ("owner" or "member")
  • customAPIKey: Optional API key to use for this request instead of the client's default API key

Returns:

  • A ProjectUser object with details about the added user
  • An error if the operation failed

func (*OpenAIClient) ChatCompletion

func (c *OpenAIClient) ChatCompletion(request *ChatCompletionRequest) (*ChatCompletionResponse, error)

ChatCompletion makes a request to the OpenAI Chat Completions API

func (*OpenAIClient) CreateAPIKey

func (c *OpenAIClient) CreateAPIKey(name string, expiresAt *int64, scopes []string) (*AdminAPIKeyResponse, error)

CreateAPIKey creates a new API key

func (*OpenAIClient) CreateInvite

func (c *OpenAIClient) CreateInvite(email, role string, projects []InviteProject) (*InviteResponse, error)

CreateInvite sends an invitation to a user to join the organization

func (*OpenAIClient) CreateModelResponse

func (c *OpenAIClient) CreateModelResponse(request *ModelResponseRequest) (*ModelResponse, error)

CreateModelResponse creates a model response using the OpenAI API

func (*OpenAIClient) CreateProject

func (c *OpenAIClient) CreateProject(name, description string, isDefault bool) (*Project, error)

CreateProject creates a new project with the given name and description

func (*OpenAIClient) CreateProjectServiceAccount

func (c *OpenAIClient) CreateProjectServiceAccount(projectID, name string) (*ProjectServiceAccount, error)

CreateProjectServiceAccount creates a new service account in a project Service accounts are bot users that are not associated with a real user and do not have the limitation of being removed when a user leaves an organization

func (*OpenAIClient) CreateRateLimit

func (c *OpenAIClient) CreateRateLimit(projectID, resourceType, limitType string, value int) (*RateLimit, error)

CreateRateLimit creates a new rate limit for a project. It allows you to set restrictions on API usage based on requests or tokens per minute.

Parameters:

  • projectID: The ID of the project to apply the rate limit to
  • resourceType: The type of resource to limit ("request" or "token")
  • limitType: The type of limit to apply ("rpm" for requests per minute or "tpm" for tokens per minute)
  • value: The numeric limit value

Returns:

  • A RateLimit object with details about the created rate limit
  • An error if the operation failed

func (*OpenAIClient) CreateVectorStore

func (c *OpenAIClient) CreateVectorStore(ctx context.Context, params *VectorStoreCreateParams) (*VectorStore, error)

CreateVectorStore creates a new vector store

func (*OpenAIClient) DeleteAPIKey

func (c *OpenAIClient) DeleteAPIKey(apiKeyID string) error

DeleteAPIKey deletes an API key

func (*OpenAIClient) DeleteInvite

func (c *OpenAIClient) DeleteInvite(inviteID string) error

DeleteInvite cancels an invitation

func (*OpenAIClient) DeleteProject

func (c *OpenAIClient) DeleteProject(id string) error

DeleteProject deletes (archives) a project by its ID

func (*OpenAIClient) DeleteProjectServiceAccount

func (c *OpenAIClient) DeleteProjectServiceAccount(projectID, serviceAccountID string) error

DeleteProjectServiceAccount removes a service account from a project

func (*OpenAIClient) DeleteRateLimit

func (c *OpenAIClient) DeleteRateLimit(projectID, modelOrRateLimitID string) error

DeleteRateLimit removes a rate limit from a project. This will allow the project to operate without this specific limitation.

Parameters:

  • projectID: The ID of the project the rate limit belongs to
  • rateLimitID: The ID of the rate limit to delete

Returns:

  • An error if the operation failed

func (*OpenAIClient) DeleteUser added in v1.1.0

func (c *OpenAIClient) DeleteUser(userID string) error

DeleteUser removes a user from the organization

func (*OpenAIClient) DeleteVectorStore

func (c *OpenAIClient) DeleteVectorStore(ctx context.Context, id string) error

DeleteVectorStore deletes a vector store by ID

func (*OpenAIClient) DoRequest

func (c *OpenAIClient) DoRequest(method, path string, body interface{}) ([]byte, error)

DoRequest performs an HTTP request with the given method, path, and body, and returns the response.

func (*OpenAIClient) FindProjectUser

func (c *OpenAIClient) FindProjectUser(projectID, userID string) (*ProjectUser, bool, error)

FindProjectUser checks if a user exists in a project by ID. This is a helper method to avoid having to iterate through users in the provider.

Parameters:

  • projectID: The ID of the project to check
  • userID: The ID of the user to find

Returns:

  • The found ProjectUser if it exists
  • A boolean indicating if the user was found
  • An error if the operation failed

func (*OpenAIClient) FindProjectUserByEmail

func (c *OpenAIClient) FindProjectUserByEmail(projectID, email string) (*ProjectUser, bool, error)

FindProjectUserByEmail checks if a user exists in a project by email address. This is a helper method to allow looking up users by email instead of ID.

Parameters:

  • projectID: The ID of the project to check
  • email: The email address of the user to find

Returns:

  • The found ProjectUser if it exists
  • A boolean indicating if the user was found
  • An error if the operation failed

func (*OpenAIClient) FindUserByEmail

func (c *OpenAIClient) FindUserByEmail(email string) (*User, bool, error)

FindUserByEmail finds a user in the organization by their email address

Parameters:

  • email: The email address of the user to find

Returns:

  • The found User if it exists
  • A boolean indicating if the user was found
  • An error if the operation failed

func (*OpenAIClient) GetAPIKey

func (c *OpenAIClient) GetAPIKey(apiKeyID string) (*AdminAPIKey, error)

GetAPIKey retrieves information about a specific API key

func (*OpenAIClient) GetInvite

func (c *OpenAIClient) GetInvite(inviteID string) (*Invite, error)

GetInvite retrieves an invitation by ID

func (*OpenAIClient) GetProject

func (c *OpenAIClient) GetProject(id string) (*Project, error)

GetProject retrieves a project by its ID

func (*OpenAIClient) GetProjectServiceAccount

func (c *OpenAIClient) GetProjectServiceAccount(projectID, serviceAccountID string) (*ProjectServiceAccount, error)

GetProjectServiceAccount retrieves information about a specific service account in a project

func (*OpenAIClient) GetRateLimit

func (c *OpenAIClient) GetRateLimit(projectID, modelOrRateLimitID string) (*RateLimit, error)

GetRateLimit retrieves information about a specific rate limit.

Parameters:

  • projectID: The ID of the project the rate limit belongs to
  • rateLimitID: The ID of the rate limit to retrieve

Returns:

  • A RateLimit object with details about the requested rate limit
  • An error if the operation failed or the rate limit doesn't exist

func (*OpenAIClient) GetUser

func (c *OpenAIClient) GetUser(userID string) (*User, bool, error)

GetUser retrieves a user by ID

func (*OpenAIClient) GetVectorStore

func (c *OpenAIClient) GetVectorStore(ctx context.Context, id string) (*VectorStore, error)

GetVectorStore retrieves a vector store by ID

func (*OpenAIClient) GetVectorStoreFile

func (c *OpenAIClient) GetVectorStoreFile(ctx context.Context, vectorStoreID, fileID string) (*VectorStoreFile, error)

GetVectorStoreFile retrieves a file from a vector store

func (*OpenAIClient) GetVectorStoreFileBatch

func (c *OpenAIClient) GetVectorStoreFileBatch(ctx context.Context, vectorStoreID, batchID string) (*VectorStoreFileBatch, error)

GetVectorStoreFileBatch retrieves a file batch from a vector store

func (*OpenAIClient) ListAPIKeys

func (c *OpenAIClient) ListAPIKeys(limit int, after string) (*ListAPIKeysResponse, error)

ListAPIKeys retrieves the list of API keys for the organization

func (*OpenAIClient) ListInvites

func (c *OpenAIClient) ListInvites() (*ListInvitesResponse, error)

ListInvites retrieves all pending invitations for the organization

func (*OpenAIClient) ListProjectServiceAccounts

func (c *OpenAIClient) ListProjectServiceAccounts(projectID string) (*ProjectServiceAccountList, error)

ListProjectServiceAccounts retrieves all service accounts in a project

func (*OpenAIClient) ListProjectUsers

func (c *OpenAIClient) ListProjectUsers(projectID string) (*ProjectUserList, error)

ListProjectUsers retrieves all users in a project. This function provides a way to check if a user is already in a project.

Parameters:

  • projectID: The ID of the project to list users from

Returns:

  • A ProjectUserList object with all users in the project
  • An error if the operation failed

func (*OpenAIClient) ListProjects

func (c *OpenAIClient) ListProjects(limit int, includeArchived bool, after string) (*ListProjectsResponse, error)

ListProjects retrieves a list of projects

func (*OpenAIClient) ListRateLimits

func (c *OpenAIClient) ListRateLimits(projectID string) (*RateLimitListResponse, error)

ListRateLimits retrieves all rate limits for a specific project.

func (*OpenAIClient) ListUsers

func (c *OpenAIClient) ListUsers(after string, limit int, emails []string) (*UsersResponse, error)

ListUsers retrieves a list of users in the organization

Parameters:

  • after: Cursor for pagination
  • limit: Maximum number of users to return
  • emails: Filter users by specific email addresses
  • customAPIKey: Optional API key to use for this request

Returns:

  • A UsersResponse object containing the list of users
  • An error if the operation failed

func (*OpenAIClient) RemoveFileBatchFromVectorStore

func (c *OpenAIClient) RemoveFileBatchFromVectorStore(ctx context.Context, vectorStoreID, batchID string) error

RemoveFileBatchFromVectorStore removes a file batch from a vector store

func (*OpenAIClient) RemoveFileFromVectorStore

func (c *OpenAIClient) RemoveFileFromVectorStore(ctx context.Context, vectorStoreID, fileID string) error

RemoveFileFromVectorStore removes a file from a vector store

func (*OpenAIClient) RemoveProjectUser

func (c *OpenAIClient) RemoveProjectUser(projectID, userID string) error

RemoveProjectUser removes a user from a project. Users who are organization owners cannot be removed from projects.

Parameters:

  • projectID: The ID of the project to remove the user from
  • userID: The ID of the user to remove

Returns:

  • An error if the operation failed

func (*OpenAIClient) SetTimeout added in v1.1.0

func (c *OpenAIClient) SetTimeout(timeout time.Duration)

SetTimeout updates the timeout for the client

func (*OpenAIClient) TestNetworkConnectivity

func (c *OpenAIClient) TestNetworkConnectivity() error

TestNetworkConnectivity tests if we can connect to the OpenAI API

func (*OpenAIClient) UpdateProject

func (c *OpenAIClient) UpdateProject(id, name, description string, isDefault bool) (*Project, error)

UpdateProject updates an existing project with the given details

func (*OpenAIClient) UpdateProjectUser

func (c *OpenAIClient) UpdateProjectUser(projectID, userID, role string) (*ProjectUser, error)

UpdateProjectUser updates a user's role in a project. Organization owners' roles cannot be modified.

Parameters:

  • projectID: The ID of the project
  • userID: The ID of the user to update
  • role: The new role to assign ("owner" or "member")

Returns:

  • A ProjectUser object with updated details
  • An error if the operation failed

func (*OpenAIClient) UpdateRateLimit

func (c *OpenAIClient) UpdateRateLimit(projectID, modelOrRateLimitID string, maxRequestsPerMinute, maxTokensPerMinute, maxImagesPerMinute, batch1DayMaxInputTokens, maxAudioMegabytesPer1Minute, maxRequestsPer1Day *int) (*RateLimit, error)

UpdateRateLimit modifies an existing rate limit for a project.

func (*OpenAIClient) UpdateUserRole

func (c *OpenAIClient) UpdateUserRole(userID string, role string) (*User, error)

UpdateUserRole updates a user's role

func (*OpenAIClient) UpdateVectorStore

func (c *OpenAIClient) UpdateVectorStore(ctx context.Context, params *VectorStoreUpdateParams) (*VectorStore, error)

UpdateVectorStore updates an existing vector store

func (*OpenAIClient) UpdateVectorStoreFile

func (c *OpenAIClient) UpdateVectorStoreFile(ctx context.Context, params *VectorStoreFileUpdateParams) (*VectorStoreFile, error)

UpdateVectorStoreFile updates a file in a vector store

func (*OpenAIClient) UpdateVectorStoreFileBatch

func (c *OpenAIClient) UpdateVectorStoreFileBatch(ctx context.Context, params *VectorStoreFileBatchUpdateParams) (*VectorStoreFileBatch, error)

UpdateVectorStoreFileBatch updates a file batch in a vector store

type Project

type Project struct {
	Object         string        `json:"object"`
	ID             string        `json:"id"`
	Name           string        `json:"name"`
	Description    string        `json:"description,omitempty"`
	OrganizationID string        `json:"organization_id,omitempty"`
	CreatedAt      *int64        `json:"created_at"`
	ArchivedAt     *int64        `json:"archived_at"`
	Status         string        `json:"status"`
	IsDefault      bool          `json:"is_default,omitempty"`
	BillingMode    string        `json:"billing_mode,omitempty"`
	APIKeys        []APIKey      `json:"api_keys,omitempty"`
	RateLimits     []RateLimit   `json:"rate_limits,omitempty"`
	Users          []ProjectUser `json:"users,omitempty"`
}

Project represents a project in OpenAI

type ProjectServiceAccount

type ProjectServiceAccount struct {
	ID        string `json:"id"`
	Object    string `json:"object"`
	Name      string `json:"name"`
	CreatedAt int64  `json:"created_at"`
	Role      string `json:"role,omitempty"`
	APIKey    *struct {
		Object    string `json:"object"`
		Value     string `json:"value,omitempty"`
		Name      string `json:"name"`
		CreatedAt int64  `json:"created_at"`
		ID        string `json:"id"`
	} `json:"api_key,omitempty"`
}

ProjectServiceAccount represents a service account in a project

type ProjectServiceAccountList

type ProjectServiceAccountList struct {
	Object  string                  `json:"object"`
	Data    []ProjectServiceAccount `json:"data"`
	FirstID string                  `json:"first_id"`
	LastID  string                  `json:"last_id"`
	HasMore bool                    `json:"has_more"`
}

ProjectServiceAccountList represents a list of service accounts in a project

type ProjectUser

type ProjectUser struct {
	Object  string `json:"object"`
	ID      string `json:"id"`
	Email   string `json:"email"`
	Role    string `json:"role"`
	AddedAt int64  `json:"added_at"`
}

ProjectUser represents a user associated with a project

type ProjectUserList

type ProjectUserList struct {
	Object  string        `json:"object"`
	Data    []ProjectUser `json:"data"`
	FirstID string        `json:"first_id"`
	LastID  string        `json:"last_id"`
	HasMore bool          `json:"has_more"`
}

ProjectUserList represents a list of users in a project

type RateLimit

type RateLimit struct {
	ID                          string `json:"id"`
	Object                      string `json:"object"`
	Model                       string `json:"model"`
	MaxRequestsPer1Minute       int    `json:"max_requests_per_1_minute"`
	MaxTokensPer1Minute         int    `json:"max_tokens_per_1_minute"`
	MaxImagesPer1Minute         int    `json:"max_images_per_1_minute"`
	Batch1DayMaxInputTokens     int    `json:"batch_1_day_max_input_tokens"`
	MaxAudioMegabytesPer1Minute int    `json:"max_audio_megabytes_per_1_minute"`
	MaxRequestsPer1Day          int    `json:"max_requests_per_1_day"`
}

RateLimit represents a rate limit configuration for a project

type RateLimitListResponse

type RateLimitListResponse struct {
	Object  string      `json:"object"`
	Data    []RateLimit `json:"data"`
	FirstID string      `json:"first_id"`
	LastID  string      `json:"last_id"`
	HasMore bool        `json:"has_more"`
}

RateLimitListResponse represents the response from the API when listing rate limits

type UpdateProjectUserRequest

type UpdateProjectUserRequest struct {
	Role string `json:"role"`
}

UpdateProjectUserRequest represents the request to update a user's role in a project

type UpdateRateLimitRequest

type UpdateRateLimitRequest struct {
	MaxRequestsPer1Minute       *int `json:"max_requests_per_1_minute,omitempty"`
	MaxTokensPer1Minute         *int `json:"max_tokens_per_1_minute,omitempty"`
	MaxImagesPer1Minute         *int `json:"max_images_per_1_minute,omitempty"`
	Batch1DayMaxInputTokens     *int `json:"batch_1_day_max_input_tokens,omitempty"`
	MaxAudioMegabytesPer1Minute *int `json:"max_audio_megabytes_per_1_minute,omitempty"`
	MaxRequestsPer1Day          *int `json:"max_requests_per_1_day,omitempty"`
}

UpdateRateLimitRequest represents the request to update a rate limit

type User

type User struct {
	ID      string `json:"id"`
	Object  string `json:"object"`
	Email   string `json:"email"`
	Name    string `json:"name"`
	Role    string `json:"role"`
	AddedAt int64  `json:"added_at"`
}

User represents an OpenAI user

type UsersResponse

type UsersResponse struct {
	Object  string `json:"object"`
	Data    []User `json:"data"`
	FirstID string `json:"first_id"`
	LastID  string `json:"last_id"`
	HasMore bool   `json:"has_more"`
}

UsersResponse represents the response from the list users API

type VectorStore

type VectorStore struct {
	ID        string            `json:"id"`
	Name      string            `json:"name"`
	FileIDs   []string          `json:"file_ids"`
	Metadata  map[string]string `json:"metadata,omitempty"`
	CreatedAt int64             `json:"created_at"`
	FileCount int               `json:"file_count"`
	Object    string            `json:"object"`
	Status    string            `json:"status"`
}

VectorStore represents an OpenAI Vector Store

type VectorStoreCreateParams

type VectorStoreCreateParams struct {
	Name             string            `json:"name"`
	FileIDs          []string          `json:"file_ids,omitempty"`
	Metadata         map[string]string `json:"metadata,omitempty"`
	ExpiresAfter     *ExpiresAfter     `json:"expires_after,omitempty"`
	ChunkingStrategy *ChunkingStrategy `json:"chunking_strategy,omitempty"`
}

VectorStoreCreateParams contains parameters for creating a vector store

type VectorStoreFile

type VectorStoreFile struct {
	ID         string            `json:"id"`
	FileID     string            `json:"file_id"`
	Attributes map[string]string `json:"attributes,omitempty"`
	CreatedAt  int64             `json:"created_at"`
	Object     string            `json:"object"`
	Status     string            `json:"status"`
}

VectorStoreFile represents a file in an OpenAI Vector Store

type VectorStoreFileBatch

type VectorStoreFileBatch struct {
	ID         string                 `json:"id"`
	FileIDs    []string               `json:"file_ids"`
	Attributes map[string]interface{} `json:"attributes,omitempty"`
	CreatedAt  int64                  `json:"created_at"`
	Object     string                 `json:"object"`
	Status     string                 `json:"status"`
}

VectorStoreFileBatch represents a batch operation for files in an OpenAI Vector Store

type VectorStoreFileBatchCreateParams

type VectorStoreFileBatchCreateParams struct {
	VectorStoreID    string                 `json:"-"`
	FileIDs          []string               `json:"file_ids"`
	Attributes       map[string]interface{} `json:"attributes,omitempty"`
	ChunkingStrategy *ChunkingStrategy      `json:"chunking_strategy,omitempty"`
}

VectorStoreFileBatchCreateParams contains parameters for adding a batch of files to a vector store

type VectorStoreFileBatchUpdateParams

type VectorStoreFileBatchUpdateParams struct {
	VectorStoreID string                 `json:"-"`
	BatchID       string                 `json:"-"`
	Attributes    map[string]interface{} `json:"attributes,omitempty"`
}

VectorStoreFileBatchUpdateParams contains parameters for updating a batch of files in a vector store

type VectorStoreFileCreateParams

type VectorStoreFileCreateParams struct {
	VectorStoreID    string            `json:"-"`
	FileID           string            `json:"file_id"`
	Attributes       map[string]string `json:"attributes,omitempty"`
	ChunkingStrategy *ChunkingStrategy `json:"chunking_strategy,omitempty"`
}

VectorStoreFileCreateParams contains parameters for adding a file to a vector store

type VectorStoreFileUpdateParams

type VectorStoreFileUpdateParams struct {
	VectorStoreID string            `json:"-"`
	FileID        string            `json:"-"`
	Attributes    map[string]string `json:"attributes,omitempty"`
}

VectorStoreFileUpdateParams contains parameters for updating a file in a vector store

type VectorStoreUpdateParams

type VectorStoreUpdateParams struct {
	ID           string            `json:"-"`
	Name         string            `json:"name,omitempty"`
	Metadata     map[string]string `json:"metadata,omitempty"`
	ExpiresAfter *ExpiresAfter     `json:"expires_after,omitempty"`
}

VectorStoreUpdateParams contains parameters for updating a vector store

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL