Skip to main content

Troubleshooting

This section provides solutions for common problems you may encounter when using the Go AI SDK. From provider errors to streaming issues, you'll find practical solutions with working code examples.

Common Issues​

The most frequent issues developers face when building AI applications with Go:

Quick Diagnostic Guide​

Error Messages​

If you see specific error messages:

Behavior Issues​

If you're experiencing specific behaviors:

Getting Help​

If you can't find a solution in this troubleshooting guide:

  1. Check the logs - Enable debug logging to see detailed error information
  2. Review the documentation - Check the API Reference for correct usage
  3. Search GitHub Issues - Your issue may already be reported or solved
  4. Create a minimal reproduction - Isolate the problem in a small example
  5. Report the issue - Open a GitHub issue with your reproduction case

Debug Mode​

The SDK has no global log-level switch. Its built-in logging hook is the warnings logger: route provider warnings to your own logger with ai.SetLogWarnings, or see Debugging for the full pattern, including wrapping the HTTP client to log raw requests and responses.

import (
"log"

"github.com/digitallysavvy/go-ai/pkg/ai"
)

func main() {
// Route SDK warnings into your own logger instead of stderr.
ai.SetLogWarnings(func(opts ai.LogWarningsOptions) {
for _, w := range opts.Warnings {
log.Printf("[%s/%s] %s", opts.Provider, opts.Model, ai.FormatWarning(w, opts.Provider, opts.Model))
}
})

// Your code here...
}

Next Steps​