f36591725a
Minor diff, MongoDB authentication only supports a specific auth methods, not the same range as all the other OYD providers. |
||
---|---|---|
.. | ||
internal | ||
testdata | ||
.gitignore | ||
CHANGELOG.md | ||
CONTRIBUTING.md | ||
LICENSE.txt | ||
README.md | ||
assets.json | ||
autorest.md | ||
build.go | ||
ci.yml | ||
client.go | ||
client_audio_internal_test.go | ||
client_audio_test.go | ||
client_batch_files_test.go | ||
client_chat_completions_extensions_test.go | ||
client_chat_completions_test.go | ||
client_completions_test.go | ||
client_custom_files.go | ||
client_embeddings_test.go | ||
client_embeddings_unit_test.go | ||
client_functions_test.go | ||
client_rai_test.go | ||
client_shared_test.go | ||
client_test.go | ||
constants.go | ||
custom_client.go | ||
custom_client_audio.go | ||
custom_client_embeddings.go | ||
custom_client_image_test.go | ||
custom_client_pagers.go | ||
custom_client_test.go | ||
custom_models.go | ||
custom_models_functions.go | ||
custom_models_test.go | ||
event_reader.go | ||
event_reader_test.go | ||
example_client_audio_test.go | ||
example_client_createimage_test.go | ||
example_client_embeddings_test.go | ||
example_client_getchatcompletions_extensions_test.go | ||
example_client_getchatcompletions_test.go | ||
example_client_getchatcompletions_vision_test.go | ||
example_client_getcompletions_test.go | ||
example_client_test.go | ||
go.mod | ||
go.sum | ||
interfaces.go | ||
main_test.go | ||
models.go | ||
models_serde.go | ||
options.go | ||
pager.go | ||
polymorphic_helpers.go | ||
responses.go | ||
sample.env | ||
test-resources.bicep | ||
time_unix.go | ||
version.go |
README.md
Azure OpenAI client module for Go
NOTE: this client can be used with Azure OpenAI and OpenAI.
Azure OpenAI Service provides access to OpenAI's features:
- Language models including the GPT-4, GPT-35-Turbo, and Embeddings model series.
- Image generation using DALL-E.
- Speech transcription and speech generation.
Source code | Package (pkg.go.dev) | REST API documentation | Product documentation
Getting started
Prerequisites
- Go, version 1.18 or higher - Install Go
- Azure subscription
- Azure OpenAI access
Install the packages
Install the azopenai
and azidentity
modules with go get
:
go get github.com/Azure/azure-sdk-for-go/sdk/ai/azopenai
# optional
go get github.com/Azure/azure-sdk-for-go/sdk/azidentity
The azidentity module is used for Azure Active Directory authentication with Azure OpenAI.
Authentication
Azure OpenAI
Azure OpenAI clients can authenticate using Azure Active Directory or with an API key:
OpenAI
OpenAI supports connecting using an API key: example
Key concepts
See Key concepts in the product documentation for more details about general concepts.
Examples
Examples for various scenarios can be found on pkg.go.dev or in the example*_test.go files in our GitHub repo for azopenai.
Troubleshooting
Error Handling
All methods that send HTTP requests return *azcore.ResponseError
when these requests fail. ResponseError
has error details and the raw response from the service.
Logging
This module uses the logging implementation in azcore
. To turn on logging for all Azure SDK modules, set AZURE_SDK_GO_LOGGING
to all
. By default, the logger writes to stderr. Use the azcore/log
package to control log output. For example, logging only HTTP request and response events, and printing them to stdout:
import azlog "github.com/Azure/azure-sdk-for-go/sdk/azcore/log"
// Print log events to stdout
azlog.SetListener(func(cls azlog.Event, msg string) {
fmt.Println(msg)
})
// Includes only requests and responses in credential logs
azlog.SetEvents(azlog.EventRequest, azlog.EventResponse)
Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.