A network cannot be accessed

I want to ask the key query of OpenAI, but under the condition of good network, I failed to access it with go code, but I can access it normally with apifox. What is the reason?

package main

import (
	"fmt"
	"io/ioutil"
	"net/http"
)

func main() {

	url1 := "https://api.openai.com/dashboard/billing/credit_grants"
	method := "GET"
	req, err := http.NewRequest(method, url1, nil)
	if err != nil {
		fmt.Println(err)
		return
	}

	var client = &http.Client{
		Transport: &http.Transport{
			Proxy: http.ProxyFromEnvironment,
		},
	}
	req.Header.Add("Accept", "*/*")
	req.Header.Add("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2")
	req.Header.Add("Authorization", "Bearer ")
	req.Header.Add("Host", "api.openai.com")
	req.Header.Add("OpenAI-Organization", "org-E6WE35xzA24xKfpTzZcZ4qhC")
	req.Header.Add("User-Agent", "Apifox/1.0.0 (https://www.apifox.cn)")
	req.Header.Add("Connection", "keep-alive")

	res, err := client.Do(req)
	if err != nil {
		fmt.Println(err)
		return
	}
	defer res.Body.Close()

	body, err := ioutil.ReadAll(res.Body)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(string(body))
}

I did not give key, he should return a web error, not inaccessible

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.