Visit https://ai.azure.com/ and create a Foundry resource, then create a new project.
Inside the project, click the Build menu at the top and click Models on the left navigation.
Choose a model like gpt-5-mini, and on the playground tab, click Continue in code.
package main
import (
"context"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/openai/openai-go/v3"
"github.com/openai/openai-go/v3/azure"
"github.com/openai/openai-go/v3/option"
"github.com/openai/openai-go/v3/responses"
)
func main() {
const endpoint = "https://redacted-resource.services.ai.azure.com/openai/v1"
const deploymentName = "gpt-5-mini"
token_credential, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
println("Error creating credential.")
panic(err)
}
client := openai.NewClient(
option.WithBaseURL(endpoint),
azure.WithTokenCredential(token_credential),
)
ctx := context.Background()
question := "Write me a haiku about computers"
resp, err := client.Responses.New(ctx, responses.ResponseNewParams{
Input: responses.ResponseNewParamsInputUnion{OfString: openai.String(question)},
Model: deploymentName,
})
if err != nil {
panic(err)
}
println(resp.OutputText())
}