Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 832307d

Browse filesBrowse files
authored
Add proxy instructions to the README (TheoKanning#173)
There are many ways to set a proxy, but this is the simplest I've seen.
1 parent ce39294 commit 832307d
Copy full SHA for 832307d

File tree

Expand file treeCollapse file tree

1 file changed

+13
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-0
lines changed

‎README.md

Copy file name to clipboardExpand all lines: README.md
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,19 @@ OpenAiApi api = retrofit.create(OpenAiApi.class);
8181
OpenAiService service = new OpenAiService(api);
8282
```
8383

84+
### Adding a Proxy
85+
To use a proxy, modify the OkHttp client as shown below:
86+
```java
87+
ObjectMapper mapper = defaultObjectMapper();
88+
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host, port));
89+
OkHttpClient client = defaultClient(token, timeout)
90+
.newBuilder()
91+
.proxy(proxy)
92+
.build();
93+
Retrofit retrofit = defaultRetrofit(client, mapper);
94+
OpenAiApi api = retrofit.create(OpenAiApi.class);
95+
OpenAiService service = new OpenAiService(api);
96+
```
8497

8598

8699

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.