The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details.
This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.
- API version: 2.1.0
- Package version: 1.0.0
- Generator version: 7.6.0
- Build package: org.openapitools.codegen.languages.GoClientCodegen For more information, please visit https://help.openai.com/
Install the following dependencies:
go get github.com/stretchr/testify/assert
go get golang.org/x/net/context
Put the package under your project folder and add the following in import:
import openai "github.com/eiixy/openai-gen"
To use a proxy, set the environment variable HTTP_PROXY
:
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
Default configuration comes with Servers
field that contains server objects as defined in the OpenAPI specification.
For using other server than the one defined on index 0 set context value openai.ContextServerIndex
of type int
.
ctx := context.WithValue(context.Background(), openai.ContextServerIndex, 1)
Templated server URL is formatted using default variables from configuration or from context value openai.ContextServerVariables
of type map[string]string
.
ctx := context.WithValue(context.Background(), openai.ContextServerVariables, map[string]string{
"basePath": "v2",
})
Note, enum values are always validated and all unused variables are silently ignored.
Each operation can use different server URL defined using OperationServers
map in the Configuration
.
An operation is uniquely identified by "{classname}Service.{nickname}"
string.
Similar rules for overriding default operation server index and variables applies by using openai.ContextOperationServerIndices
and openai.ContextOperationServerVariables
context maps.
ctx := context.WithValue(context.Background(), openai.ContextOperationServerIndices, map[string]int{
"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), openai.ContextOperationServerVariables, map[string]map[string]string{
"{classname}Service.{nickname}": {
"port": "8443",
},
})
All URIs are relative to https://api.openai.com/v1
Class | Method | HTTP request | Description |
---|---|---|---|
AssistantsAPI | CancelRun | Post /threads/{thread_id}/runs/{run_id}/cancel | Cancels a run that is `in_progress`. |
AssistantsAPI | CreateAssistant | Post /assistants | Create an assistant with a model and instructions. |
AssistantsAPI | CreateMessage | Post /threads/{thread_id}/messages | Create a message. |
AssistantsAPI | CreateRun | Post /threads/{thread_id}/runs | Create a run. |
AssistantsAPI | CreateThread | Post /threads | Create a thread. |
AssistantsAPI | CreateThreadAndRun | Post /threads/runs | Create a thread and run it in one request. |
AssistantsAPI | DeleteAssistant | Delete /assistants/{assistant_id} | Delete an assistant. |
AssistantsAPI | DeleteMessage | Delete /threads/{thread_id}/messages/{message_id} | Deletes a message. |
AssistantsAPI | DeleteThread | Delete /threads/{thread_id} | Delete a thread. |
AssistantsAPI | GetAssistant | Get /assistants/{assistant_id} | Retrieves an assistant. |
AssistantsAPI | GetMessage | Get /threads/{thread_id}/messages/{message_id} | Retrieve a message. |
AssistantsAPI | GetRun | Get /threads/{thread_id}/runs/{run_id} | Retrieves a run. |
AssistantsAPI | GetRunStep | Get /threads/{thread_id}/runs/{run_id}/steps/{step_id} | Retrieves a run step. |
AssistantsAPI | GetThread | Get /threads/{thread_id} | Retrieves a thread. |
AssistantsAPI | ListAssistants | Get /assistants | Returns a list of assistants. |
AssistantsAPI | ListMessages | Get /threads/{thread_id}/messages | Returns a list of messages for a given thread. |
AssistantsAPI | ListRunSteps | Get /threads/{thread_id}/runs/{run_id}/steps | Returns a list of run steps belonging to a run. |
AssistantsAPI | ListRuns | Get /threads/{thread_id}/runs | Returns a list of runs belonging to a thread. |
AssistantsAPI | ModifyAssistant | Post /assistants/{assistant_id} | Modifies an assistant. |
AssistantsAPI | ModifyMessage | Post /threads/{thread_id}/messages/{message_id} | Modifies a message. |
AssistantsAPI | ModifyRun | Post /threads/{thread_id}/runs/{run_id} | Modifies a run. |
AssistantsAPI | ModifyThread | Post /threads/{thread_id} | Modifies a thread. |
AssistantsAPI | SubmitToolOuputsToRun | Post /threads/{thread_id}/runs/{run_id}/submit_tool_outputs | When a run has the `status: "requires_action"` and `required_action.type` is `submit_tool_outputs`, this endpoint can be used to submit the outputs from the tool calls once they're all completed. All outputs must be submitted in a single request. |
AudioAPI | CreateSpeech | Post /audio/speech | Generates audio from the input text. |
AudioAPI | CreateTranscription | Post /audio/transcriptions | Transcribes audio into the input language. |
AudioAPI | CreateTranslation | Post /audio/translations | Translates audio into English. |
BatchAPI | CancelBatch | Post /batches/{batch_id}/cancel | Cancels an in-progress batch. The batch will be in status `cancelling` for up to 10 minutes, before changing to `cancelled`, where it will have partial results (if any) available in the output file. |
BatchAPI | CreateBatch | Post /batches | Creates and executes a batch from an uploaded file of requests |
BatchAPI | ListBatches | Get /batches | List your organization's batches. |
BatchAPI | RetrieveBatch | Get /batches/{batch_id} | Retrieves a batch. |
ChatAPI | CreateChatCompletion | Post /chat/completions | Creates a model response for the given chat conversation. |
CompletionsAPI | CreateCompletion | Post /completions | Creates a completion for the provided prompt and parameters. |
EmbeddingsAPI | CreateEmbedding | Post /embeddings | Creates an embedding vector representing the input text. |
FilesAPI | CreateFile | Post /files | Upload a file that can be used across various endpoints. Individual files can be up to 512 MB, and the size of all files uploaded by one organization can be up to 100 GB. The Assistants API supports files up to 2 million tokens and of specific file types. See the Assistants Tools guide for details. The Fine-tuning API only supports `.jsonl` files. The input also has certain required formats for fine-tuning chat or completions models. The Batch API only supports `.jsonl` files up to 100 MB in size. The input also has a specific required format. Please contact us if you need to increase these storage limits. |
FilesAPI | DeleteFile | Delete /files/{file_id} | Delete a file. |
FilesAPI | DownloadFile | Get /files/{file_id}/content | Returns the contents of the specified file. |
FilesAPI | ListFiles | Get /files | Returns a list of files that belong to the user's organization. |
FilesAPI | RetrieveFile | Get /files/{file_id} | Returns information about a specific file. |
FineTuningAPI | CancelFineTuningJob | Post /fine_tuning/jobs/{fine_tuning_job_id}/cancel | Immediately cancel a fine-tune job. |
FineTuningAPI | CreateFineTuningJob | Post /fine_tuning/jobs | Creates a fine-tuning job which begins the process of creating a new model from a given dataset. Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete. Learn more about fine-tuning |
FineTuningAPI | ListFineTuningEvents | Get /fine_tuning/jobs/{fine_tuning_job_id}/events | Get status updates for a fine-tuning job. |
FineTuningAPI | ListFineTuningJobCheckpoints | Get /fine_tuning/jobs/{fine_tuning_job_id}/checkpoints | List checkpoints for a fine-tuning job. |
FineTuningAPI | ListPaginatedFineTuningJobs | Get /fine_tuning/jobs | List your organization's fine-tuning jobs |
FineTuningAPI | RetrieveFineTuningJob | Get /fine_tuning/jobs/{fine_tuning_job_id} | Get info about a fine-tuning job. Learn more about fine-tuning |
ImagesAPI | CreateImage | Post /images/generations | Creates an image given a prompt. |
ImagesAPI | CreateImageEdit | Post /images/edits | Creates an edited or extended image given an original image and a prompt. |
ImagesAPI | CreateImageVariation | Post /images/variations | Creates a variation of a given image. |
ModelsAPI | DeleteModel | Delete /models/{model} | Delete a fine-tuned model. You must have the Owner role in your organization to delete a model. |
ModelsAPI | ListModels | Get /models | Lists the currently available models, and provides basic information about each one such as the owner and availability. |
ModelsAPI | RetrieveModel | Get /models/{model} | Retrieves a model instance, providing basic information about the model such as the owner and permissioning. |
ModerationsAPI | CreateModeration | Post /moderations | Classifies if text is potentially harmful. |
VectorStoresAPI | CancelVectorStoreFileBatch | Post /vector_stores/{vector_store_id}/file_batches/{batch_id}/cancel | Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible. |
VectorStoresAPI | CreateVectorStore | Post /vector_stores | Create a vector store. |
VectorStoresAPI | CreateVectorStoreFile | Post /vector_stores/{vector_store_id}/files | Create a vector store file by attaching a File to a vector store. |
VectorStoresAPI | CreateVectorStoreFileBatch | Post /vector_stores/{vector_store_id}/file_batches | Create a vector store file batch. |
VectorStoresAPI | DeleteVectorStore | Delete /vector_stores/{vector_store_id} | Delete a vector store. |
VectorStoresAPI | DeleteVectorStoreFile | Delete /vector_stores/{vector_store_id}/files/{file_id} | Delete a vector store file. This will remove the file from the vector store but the file itself will not be deleted. To delete the file, use the delete file endpoint. |
VectorStoresAPI | GetVectorStore | Get /vector_stores/{vector_store_id} | Retrieves a vector store. |
VectorStoresAPI | GetVectorStoreFile | Get /vector_stores/{vector_store_id}/files/{file_id} | Retrieves a vector store file. |
VectorStoresAPI | GetVectorStoreFileBatch | Get /vector_stores/{vector_store_id}/file_batches/{batch_id} | Retrieves a vector store file batch. |
VectorStoresAPI | ListFilesInVectorStoreBatch | Get /vector_stores/{vector_store_id}/file_batches/{batch_id}/files | Returns a list of vector store files in a batch. |
VectorStoresAPI | ListVectorStoreFiles | Get /vector_stores/{vector_store_id}/files | Returns a list of vector store files. |
VectorStoresAPI | ListVectorStores | Get /vector_stores | Returns a list of vector stores. |
VectorStoresAPI | ModifyVectorStore | Post /vector_stores/{vector_store_id} | Modifies a vector store. |
- ArrayOfContentPartsInner
- AssistantObject
- AssistantObjectToolResources
- AssistantObjectToolResourcesCodeInterpreter
- AssistantObjectToolResourcesFileSearch
- AssistantObjectToolsInner
- AssistantStreamEvent
- AssistantToolsCode
- AssistantToolsFileSearch
- AssistantToolsFileSearchFileSearch
- AssistantToolsFileSearchTypeOnly
- AssistantToolsFunction
- AssistantsApiResponseFormat
- AssistantsApiResponseFormatOption
- AssistantsApiToolChoiceOption
- AssistantsNamedToolChoice
- AutoChunkingStrategy
- AutoChunkingStrategyRequestParam
- Batch
- BatchErrors
- BatchErrorsDataInner
- BatchRequestCounts
- BatchRequestInput
- BatchRequestOutput
- BatchRequestOutputError
- BatchRequestOutputResponse
- ChatCompletionFunctionCallOption
- ChatCompletionFunctions
- ChatCompletionMessageToolCall
- ChatCompletionMessageToolCallChunk
- ChatCompletionMessageToolCallChunkFunction
- ChatCompletionMessageToolCallFunction
- ChatCompletionNamedToolChoice
- ChatCompletionNamedToolChoiceFunction
- ChatCompletionRequestAssistantMessage
- ChatCompletionRequestAssistantMessageFunctionCall
- ChatCompletionRequestFunctionMessage
- ChatCompletionRequestMessage
- ChatCompletionRequestMessageContentPart
- ChatCompletionRequestMessageContentPartImage
- ChatCompletionRequestMessageContentPartImageImageUrl
- ChatCompletionRequestMessageContentPartText
- ChatCompletionRequestSystemMessage
- ChatCompletionRequestToolMessage
- ChatCompletionRequestUserMessage
- ChatCompletionRequestUserMessageContent
- ChatCompletionResponseMessage
- ChatCompletionResponseMessageFunctionCall
- ChatCompletionRole
- ChatCompletionStreamOptions
- ChatCompletionStreamResponseDelta
- ChatCompletionStreamResponseDeltaFunctionCall
- ChatCompletionTokenLogprob
- ChatCompletionTokenLogprobTopLogprobsInner
- ChatCompletionTool
- ChatCompletionToolChoiceOption
- ChunkingStrategyRequestParam
- CompletionUsage
- CreateAssistantRequest
- CreateAssistantRequestModel
- CreateAssistantRequestToolResources
- CreateAssistantRequestToolResourcesCodeInterpreter
- CreateAssistantRequestToolResourcesFileSearch
- CreateAssistantRequestToolResourcesFileSearchVectorStoresInner
- CreateAssistantRequestToolResourcesFileSearchVectorStoresInnerChunkingStrategy
- CreateBatchRequest
- CreateChatCompletionFunctionResponse
- CreateChatCompletionFunctionResponseChoicesInner
- CreateChatCompletionRequest
- CreateChatCompletionRequestFunctionCall
- CreateChatCompletionRequestModel
- CreateChatCompletionRequestResponseFormat
- CreateChatCompletionRequestStop
- CreateChatCompletionResponse
- CreateChatCompletionResponseChoicesInner
- CreateChatCompletionResponseChoicesInnerLogprobs
- CreateChatCompletionStreamResponse
- CreateChatCompletionStreamResponseChoicesInner
- CreateChatCompletionStreamResponseUsage
- CreateCompletionRequest
- CreateCompletionRequestModel
- CreateCompletionRequestPrompt
- CreateCompletionRequestStop
- CreateCompletionResponse
- CreateCompletionResponseChoicesInner
- CreateCompletionResponseChoicesInnerLogprobs
- CreateEmbeddingRequest
- CreateEmbeddingRequestInput
- CreateEmbeddingRequestModel
- CreateEmbeddingResponse
- CreateEmbeddingResponseUsage
- CreateFineTuningJobRequest
- CreateFineTuningJobRequestHyperparameters
- CreateFineTuningJobRequestHyperparametersBatchSize
- CreateFineTuningJobRequestHyperparametersLearningRateMultiplier
- CreateFineTuningJobRequestHyperparametersNEpochs
- CreateFineTuningJobRequestIntegrationsInner
- CreateFineTuningJobRequestIntegrationsInnerType
- CreateFineTuningJobRequestIntegrationsInnerWandb
- CreateFineTuningJobRequestModel
- CreateImageEditRequestModel
- CreateImageRequest
- CreateImageRequestModel
- CreateMessageRequest
- CreateMessageRequestContent
- CreateModerationRequest
- CreateModerationRequestInput
- CreateModerationRequestModel
- CreateModerationResponse
- CreateModerationResponseResultsInner
- CreateModerationResponseResultsInnerCategories
- CreateModerationResponseResultsInnerCategoryScores
- CreateRunRequest
- CreateRunRequestModel
- CreateSpeechRequest
- CreateSpeechRequestModel
- CreateThreadAndRunRequest
- CreateThreadAndRunRequestToolResources
- CreateThreadAndRunRequestToolsInner
- CreateThreadRequest
- CreateThreadRequestToolResources
- CreateThreadRequestToolResourcesFileSearch
- CreateThreadRequestToolResourcesFileSearchVectorStoresInner
- CreateTranscription200Response
- CreateTranscriptionRequestModel
- CreateTranscriptionResponseJson
- CreateTranscriptionResponseVerboseJson
- CreateTranslation200Response
- CreateTranslationResponseJson
- CreateTranslationResponseVerboseJson
- CreateVectorStoreFileBatchRequest
- CreateVectorStoreFileRequest
- CreateVectorStoreRequest
- CreateVectorStoreRequestChunkingStrategy
- DeleteAssistantResponse
- DeleteFileResponse
- DeleteMessageResponse
- DeleteModelResponse
- DeleteThreadResponse
- DeleteVectorStoreFileResponse
- DeleteVectorStoreResponse
- DoneEvent
- Embedding
- Error
- ErrorEvent
- ErrorResponse
- FineTuneChatCompletionRequestAssistantMessage
- FineTuningIntegration
- FineTuningJob
- FineTuningJobCheckpoint
- FineTuningJobCheckpointMetrics
- FineTuningJobError
- FineTuningJobEvent
- FineTuningJobHyperparameters
- FineTuningJobHyperparametersNEpochs
- FineTuningJobIntegrationsInner
- FinetuneChatRequestInput
- FinetuneChatRequestInputMessagesInner
- FinetuneCompletionRequestInput
- FunctionObject
- Image
- ImagesResponse
- ListAssistantsResponse
- ListBatchesResponse
- ListFilesResponse
- ListFineTuningJobCheckpointsResponse
- ListFineTuningJobEventsResponse
- ListMessagesResponse
- ListModelsResponse
- ListPaginatedFineTuningJobsResponse
- ListRunStepsResponse
- ListRunsResponse
- ListThreadsResponse
- ListVectorStoreFilesResponse
- ListVectorStoresResponse
- MessageContentImageFileObject
- MessageContentImageFileObjectImageFile
- MessageContentImageUrlObject
- MessageContentImageUrlObjectImageUrl
- MessageContentTextAnnotationsFileCitationObject
- MessageContentTextAnnotationsFileCitationObjectFileCitation
- MessageContentTextAnnotationsFilePathObject
- MessageContentTextAnnotationsFilePathObjectFilePath
- MessageContentTextObject
- MessageContentTextObjectText
- MessageContentTextObjectTextAnnotationsInner
- MessageDeltaContentImageFileObject
- MessageDeltaContentImageFileObjectImageFile
- MessageDeltaContentImageUrlObject
- MessageDeltaContentImageUrlObjectImageUrl
- MessageDeltaContentTextAnnotationsFileCitationObject
- MessageDeltaContentTextAnnotationsFileCitationObjectFileCitation
- MessageDeltaContentTextAnnotationsFilePathObject
- MessageDeltaContentTextAnnotationsFilePathObjectFilePath
- MessageDeltaContentTextObject
- MessageDeltaContentTextObjectText
- MessageDeltaContentTextObjectTextAnnotationsInner
- MessageDeltaObject
- MessageDeltaObjectDelta
- MessageDeltaObjectDeltaContentInner
- MessageObject
- MessageObjectAttachmentsInner
- MessageObjectAttachmentsInnerToolsInner
- MessageObjectContentInner
- MessageObjectIncompleteDetails
- MessageRequestContentTextObject
- MessageStreamEvent
- MessageStreamEventOneOf
- MessageStreamEventOneOf1
- MessageStreamEventOneOf2
- MessageStreamEventOneOf3
- MessageStreamEventOneOf4
- Model
- ModifyAssistantRequest
- ModifyAssistantRequestToolResources
- ModifyAssistantRequestToolResourcesCodeInterpreter
- ModifyAssistantRequestToolResourcesFileSearch
- ModifyMessageRequest
- ModifyRunRequest
- ModifyThreadRequest
- OpenAIFile
- OtherChunkingStrategyResponseParam
- RunCompletionUsage
- RunObject
- RunObjectIncompleteDetails
- RunObjectLastError
- RunObjectRequiredAction
- RunObjectRequiredActionSubmitToolOutputs
- RunStepCompletionUsage
- RunStepDeltaObject
- RunStepDeltaObjectDelta
- RunStepDeltaObjectDeltaStepDetails
- RunStepDeltaStepDetailsMessageCreationObject
- RunStepDeltaStepDetailsMessageCreationObjectMessageCreation
- RunStepDeltaStepDetailsToolCallsCodeObject
- RunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter
- RunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsInner
- RunStepDeltaStepDetailsToolCallsCodeOutputImageObject
- RunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage
- RunStepDeltaStepDetailsToolCallsCodeOutputLogsObject
- RunStepDeltaStepDetailsToolCallsFileSearchObject
- RunStepDeltaStepDetailsToolCallsFunctionObject
- RunStepDeltaStepDetailsToolCallsFunctionObjectFunction
- RunStepDeltaStepDetailsToolCallsObject
- RunStepDeltaStepDetailsToolCallsObjectToolCallsInner
- RunStepDetailsMessageCreationObject
- RunStepDetailsMessageCreationObjectMessageCreation
- RunStepDetailsToolCallsCodeObject
- RunStepDetailsToolCallsCodeObjectCodeInterpreter
- RunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsInner
- RunStepDetailsToolCallsCodeOutputImageObject
- RunStepDetailsToolCallsCodeOutputImageObjectImage
- RunStepDetailsToolCallsCodeOutputLogsObject
- RunStepDetailsToolCallsFileSearchObject
- RunStepDetailsToolCallsFunctionObject
- RunStepDetailsToolCallsFunctionObjectFunction
- RunStepDetailsToolCallsObject
- RunStepDetailsToolCallsObjectToolCallsInner
- RunStepObject
- RunStepObjectLastError
- RunStepObjectStepDetails
- RunStepStreamEvent
- RunStepStreamEventOneOf
- RunStepStreamEventOneOf1
- RunStepStreamEventOneOf2
- RunStepStreamEventOneOf3
- RunStepStreamEventOneOf4
- RunStepStreamEventOneOf5
- RunStepStreamEventOneOf6
- RunStreamEvent
- RunStreamEventOneOf
- RunStreamEventOneOf1
- RunStreamEventOneOf2
- RunStreamEventOneOf3
- RunStreamEventOneOf4
- RunStreamEventOneOf5
- RunStreamEventOneOf6
- RunStreamEventOneOf7
- RunStreamEventOneOf8
- RunStreamEventOneOf9
- RunToolCallObject
- RunToolCallObjectFunction
- StaticChunkingStrategy
- StaticChunkingStrategyRequestParam
- StaticChunkingStrategyResponseParam
- StaticChunkingStrategyStatic
- SubmitToolOutputsRunRequest
- SubmitToolOutputsRunRequestToolOutputsInner
- ThreadObject
- ThreadObjectToolResources
- ThreadObjectToolResourcesFileSearch
- ThreadStreamEvent
- ThreadStreamEventOneOf
- TranscriptionSegment
- TranscriptionWord
- TruncationObject
- UpdateVectorStoreRequest
- VectorStoreExpirationAfter
- VectorStoreFileBatchObject
- VectorStoreFileBatchObjectFileCounts
- VectorStoreFileObject
- VectorStoreFileObjectChunkingStrategy
- VectorStoreFileObjectLastError
- VectorStoreObject
- VectorStoreObjectFileCounts
Authentication schemes defined for the API:
- Type: HTTP Bearer token authentication
Example
auth := context.WithValue(context.Background(), openai.ContextAccessToken, "BEARER_TOKEN_STRING")
r, err := client.Service.Operation(auth, args)
Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:
PtrBool
PtrInt
PtrInt32
PtrInt64
PtrFloat
PtrFloat32
PtrFloat64
PtrString
PtrTime