azure-sdk-for-go/sdk/ai/azopenai
Richard Park f36591725a
[azopenai] Fixing incorrect type for MongoDB auth (#23620)
Minor diff, MongoDB authentication only supports a specific auth methods, not the same range as all the other OYD providers.
2024-10-22 15:17:31 -07:00
..
internal [azopenai] 2024-08-01-preview generation (#23554) 2024-10-11 11:26:46 -07:00
testdata [azopenai] Fixing incorrect type for MongoDB auth (#23620) 2024-10-22 15:17:31 -07:00
.gitignore [azopenai] Updating for the 2024-02-15-preview (#22447) 2024-03-04 20:33:06 -08:00
CHANGELOG.md [azopenai] Fixing incorrect type for MongoDB auth (#23620) 2024-10-22 15:17:31 -07:00
CONTRIBUTING.md [azopenai] Adding in a contributors guide, some documentation to explain how bits fit together. (#21609) 2023-09-28 13:15:15 -07:00
LICENSE.txt [azopenai] Move azopenai from `cognitiveservices/azopenai` to `ai/azopenai` (#21264) 2023-07-26 18:08:02 +00:00
README.md Update README.md (#22633) 2024-03-25 16:41:49 +00:00
assets.json [azopenai] 2024-08-01-preview generation (#23554) 2024-10-11 11:26:46 -07:00
autorest.md [azopenai] 2024-08-01-preview generation (#23554) 2024-10-11 11:26:46 -07:00
build.go [azopenai] 2024-08-01-preview generation (#23554) 2024-10-11 11:26:46 -07:00
ci.yml Switch to TME test subscription (#23570) 2024-10-14 16:54:41 -07:00
client.go [azopenai] 2024-08-01-preview generation (#23554) 2024-10-11 11:26:46 -07:00
client_audio_internal_test.go [azopenai] Updating for the 2024-02-15-preview (#22447) 2024-03-04 20:33:06 -08:00
client_audio_test.go Upgrade test proxy, broken tests run only in live and recording modes 2024-05-08 17:24:07 -07:00
client_batch_files_test.go [azopenai] 2024-08-01-preview generation (#23554) 2024-10-11 11:26:46 -07:00
client_chat_completions_extensions_test.go [azopenai] Fixing issue where content filtering being non-deterministic is making tests fail. (#23490) 2024-09-25 20:15:32 +00:00
client_chat_completions_test.go [azopenai] 2024-08-01-preview generation (#23554) 2024-10-11 11:26:46 -07:00
client_completions_test.go [azopenai] A rather large, but needed, cleanup of the tests. (#22707) 2024-04-17 15:19:32 -07:00
client_custom_files.go [azopenai] Updates for 2024-07-01 (#23362) 2024-09-10 18:47:12 +00:00
client_embeddings_test.go [azopenai] A rather large, but needed, cleanup of the tests. (#22707) 2024-04-17 15:19:32 -07:00
client_embeddings_unit_test.go [azopenai] Adding in support for the latest preview: 2024-03-01 (#22603) 2024-03-21 10:38:24 -07:00
client_functions_test.go [azopenai] 2024-08-01-preview generation (#23554) 2024-10-11 11:26:46 -07:00
client_rai_test.go [azopenai] 2024-08-01-preview generation (#23554) 2024-10-11 11:26:46 -07:00
client_shared_test.go [azopenai] 2024-08-01-preview generation (#23554) 2024-10-11 11:26:46 -07:00
client_test.go [azopenai] 2024-08-01-preview generation (#23554) 2024-10-11 11:26:46 -07:00
constants.go [azopenai] 2024-08-01-preview generation (#23554) 2024-10-11 11:26:46 -07:00
custom_client.go [azopenai] 2024-08-01-preview generation (#23554) 2024-10-11 11:26:46 -07:00
custom_client_audio.go [azopenai] Updates for 2024-07-01 (#23362) 2024-09-10 18:47:12 +00:00
custom_client_embeddings.go [azopenai] 2024-08-01-preview generation (#23554) 2024-10-11 11:26:46 -07:00
custom_client_image_test.go [azopenai] Updating API version `2024-05-01` (#22967) 2024-06-04 11:50:56 -07:00
custom_client_pagers.go [azopenai] Updates for 2024-07-01 (#23362) 2024-09-10 18:47:12 +00:00
custom_client_test.go [azopenai] Updates for 2024-07-01 (#23362) 2024-09-10 18:47:12 +00:00
custom_models.go [azopenai] 2024-08-01-preview generation (#23554) 2024-10-11 11:26:46 -07:00
custom_models_functions.go [azopenai] Updating to the latest 2023-12-01 API (#22081) 2023-12-07 12:33:38 -08:00
custom_models_test.go [azopenai] Updating to the latest 2023-12-01 API (#22081) 2023-12-07 12:33:38 -08:00
event_reader.go [azopenai] Switch EventReader from using bufio.Scanner to bufio.Reader (#22703) 2024-04-05 13:53:56 -07:00
event_reader_test.go [azopenai] Switch EventReader from using bufio.Scanner to bufio.Reader (#22703) 2024-04-05 13:53:56 -07:00
example_client_audio_test.go [azopenai] Updating changelog for new release. (#23042) 2024-06-11 14:45:52 -07:00
example_client_createimage_test.go [azopenai] Updating changelog for new release. (#23042) 2024-06-11 14:45:52 -07:00
example_client_embeddings_test.go [azopenai] Updating changelog for new release. (#23042) 2024-06-11 14:45:52 -07:00
example_client_getchatcompletions_extensions_test.go [azopenai] Updating changelog for new release. (#23042) 2024-06-11 14:45:52 -07:00
example_client_getchatcompletions_test.go [azopenai] 2024-08-01-preview generation (#23554) 2024-10-11 11:26:46 -07:00
example_client_getchatcompletions_vision_test.go [azopenai] Updating changelog for new release. (#23042) 2024-06-11 14:45:52 -07:00
example_client_getcompletions_test.go [azopenai] Updating changelog for new release. (#23042) 2024-06-11 14:45:52 -07:00
example_client_test.go [azopenai] Updating changelog for new release. (#23042) 2024-06-11 14:45:52 -07:00
go.mod [azopenai] 2024-08-01-preview generation (#23554) 2024-10-11 11:26:46 -07:00
go.sum [azopenai] 2024-08-01-preview generation (#23554) 2024-10-11 11:26:46 -07:00
interfaces.go [azopenai] 2024-08-01-preview generation (#23554) 2024-10-11 11:26:46 -07:00
main_test.go [azopenai] Make sure all the examples are runnable. (#22770) 2024-05-02 07:53:20 -07:00
models.go [azopenai] Fixing incorrect type for MongoDB auth (#23620) 2024-10-22 15:17:31 -07:00
models_serde.go [azopenai] Fixing incorrect type for MongoDB auth (#23620) 2024-10-22 15:17:31 -07:00
options.go [azopenai] 2024-08-01-preview generation (#23554) 2024-10-11 11:26:46 -07:00
pager.go [azopenai] Updates for 2024-07-01 (#23362) 2024-09-10 18:47:12 +00:00
polymorphic_helpers.go [azopenai] 2024-08-01-preview generation (#23554) 2024-10-11 11:26:46 -07:00
responses.go [azopenai] 2024-08-01-preview generation (#23554) 2024-10-11 11:26:46 -07:00
sample.env [azopenai] Add in whisper (audio transcription and translation) support (#21599) 2023-09-21 18:06:33 -07:00
test-resources.bicep Add copyright header to bicep files (#22576) 2024-03-12 08:36:51 -07:00
time_unix.go [azopenai] Updating for the 2024-02-15-preview (#22447) 2024-03-04 20:33:06 -08:00
version.go Increment package version after release of ai/azopenai (#23584) 2024-10-14 20:05:20 +00:00

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

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:

  • Using Azure Active Directory, with a TokenCredential: example
  • Using an API key: example

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.