Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/main/java/com/google/genai/ApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
import com.google.genai.types.ClientOptions;
import com.google.genai.types.HttpOptions;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.SocketAddress;
import java.time.Duration;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -233,7 +236,9 @@ private OkHttpClient createHttpClient(
options.maxConnectionsPerHost().ifPresent(dispatcher::setMaxRequestsPerHost);
builder.dispatcher(dispatcher);
});

if (httpOptions != null) {
httpOptions.proxy().ifPresent(builder::proxy);
}
return builder.build();
}

Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/google/genai/types/HttpOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.google.auto.value.AutoValue;
import com.google.genai.JsonSerializable;
import java.net.Proxy;
import java.util.Map;
import java.util.Optional;

Expand All @@ -46,6 +47,10 @@ public abstract class HttpOptions extends JsonSerializable {
@JsonProperty("timeout")
public abstract Optional<Integer> timeout();

/** Proxy configuration for the HTTP requests. */
@JsonProperty("proxy")
public abstract Optional<Proxy> proxy();

/**
* Extra parameters to add to the request body. The structure must match the backend API's request
* structure. - VertexAI backend API docs: https://cloud.google.com/vertex-ai/docs/reference/rest
Expand Down Expand Up @@ -103,6 +108,14 @@ private static Builder create() {
@JsonProperty("timeout")
public abstract Builder timeout(Integer timeout);

/**
* Setter for proxy.
*
* <p>proxy: Proxy configuration for the HTTP requests.
*/
@JsonProperty("proxy")
public abstract Builder proxy(Proxy proxy);

/**
* Setter for extraBody.
*
Expand Down