const axios = require('axios');
const http = require('http');
const https = require('https');
// Create an HTTP agent
const httpAgent = new http.Agent({
localAddress: '192.168.1.100' // Your local IP here
});
// Optionally, create an HTTPS agent if needed
const httpsAgent = new https.Agent({
localAddress: '192.168.1.100' // Your local IP here
});
// Use Axios to make a request
axios.get('http://example.com', {
httpAgent: httpAgent,
httpsAgent: httpsAgent
})
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error('Request failed:', error);
});
当 VPS有多个 IP时,能否增加向 openai 发出请求时指定IP的功能?
目前支持ipv6的 VPS可添加的 IP数量接近无限,这个功能应该还是很有用的。将多个IPV6都添加到 vps上,请求openai时轮换使用。
附 1 axios 指定IP样例: