Mavera’s Responses API is compatible with OpenAI’s API shape. The go-openai library does not yet support the Responses API, so the REST approach with net/http is the primary method. You can still use go-openai for other OpenAI-compatible operations.
Model name: The go-openai library may use gpt-4 or similar. Mavera expects mavera-1. Check the library’s Model constant or pass "mavera-1" as a string. Note that go-openai’s CreateChatCompletion does not support the Responses API — use the REST approach below for full Mavera compatibility.
The go-openai library doesn’t expose persona_id on the request struct. You can:
Use a forked or extended client that adds Mavera fields
Inject via a custom request if the library supports extra fields
Use the REST API directly with net/http for full control
Example with REST (no SDK):
package mainimport ( "bytes" "encoding/json" "fmt" "net/http" "os")func main() { apiKey := os.Getenv("MAVERA_API_KEY") if apiKey == "" { panic("Set MAVERA_API_KEY") } body := map[string]interface{}{ "model": "mavera-1", "input": "What matters most when choosing a product?", "persona_id": "YOUR_PERSONA_ID", } jsonBody, _ := json.Marshal(body) req, _ := http.NewRequest("POST", "https://app.mavera.io/api/v1/responses", bytes.NewReader(jsonBody)) req.Header.Set("Authorization", "Bearer "+apiKey) req.Header.Set("Content-Type", "application/json") resp, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer resp.Body.Close() var result struct { Output []struct { Content []struct { Text string `json:"text"` } `json:"content"` } `json:"output"` Usage struct { CreditsUsed int `json:"credits_used"` } `json:"usage"` } if err := json.NewDecoder(resp.Body).Decode(&result); err != nil { panic(err) } if len(result.Output) > 0 && len(result.Output[0].Content) > 0 { fmt.Println(result.Output[0].Content[0].Text) fmt.Printf("Credits used: %d\n", result.Usage.CreditsUsed) }}
For production, use a proper HTTP client, error handling, and avoid re-issuing requests. The REST approach gives you full control over persona_id, input, and other Mavera fields.