Access to OpenAI models through Google Cloud is currently in private preview. To use them in your project, request access.
OpenAI models are available on the Gemini platform through Google Cloud, with usage billed to your Google Cloud account. The models run within Google Cloud’s security perimeter, and your organization manages access through Google Cloud IAM.
This guide covers how to make a Responses API request through Google Cloud and how feature support differs from the first-party OpenAI API.
The following models are available:
| Model |
Model ID |
| GPT-6.2 Astra |
gpt-6.2-astra |
| GPT-6.2 Sol |
gpt-6.2-sol |
| GPT-6 Luna |
gpt-6-luna |
| GPT-6.1 Sol |
gpt-6.1-sol |
| GPT-6.1 Terra |
gpt-6.1-terra |
| GPT-6 Astra |
gpt-6-astra |
Before you can make requests, your Google Cloud administrator needs to:
- Enable billing for the project, arrange project approval, and coordinate acceptance of the Marketplace private offer with your billing administrator.
- Enable the Vertex AI API (
aiplatform.googleapis.com) and the model in Model Garden, including acceptance of the model terms.
- If your organization’s policy restricts model access, allow the model in that policy.
- Grant the user or service account making requests permission to call the model, for example by assigning the
roles/aiplatform.user role.
Once the project is ready, ask your administrator for the project ID.
For local development, install the Google Cloud CLI and sign in with the Google account that has access to your project:
gcloud auth application-default login
Get an access token in the terminal where you’ll run the request:
export GOOGLE_CLOUD_ACCESS_TOKEN="$(gcloud auth application-default print-access-token)"
When the access token expires, run this command again to get a new one using your saved sign-in.
Send the request with cURL or the OpenAI SDK, replacing your-project-id with your project ID.
1
2
3
4
5
6
7
8
9
10
11PROJECT_ID="your-project-id"
PROJECT_URL="https://aiplatform.googleapis.com/v1/projects/$PROJECT_ID"
curl --fail-with-body "$PROJECT_URL/locations/global/publishers/openai/v1/responses" \
-H "Authorization: Bearer $GOOGLE_CLOUD_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6-luna",
"input": "Write a one-sentence bedtime story about a unicorn.",
"store": false
}'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16import OpenAI from "openai";
const projectId = "your-project-id";
const client = new OpenAI({
apiKey: process.env.GOOGLE_CLOUD_ACCESS_TOKEN,
baseURL: `https://aiplatform.googleapis.com/v1/projects/${projectId}/locations/global/publishers/openai/v1`,
});
const response = await client.responses.create({
model: "gpt-6-luna",
input: "Write a one-sentence bedtime story about a unicorn.",
store: false,
});
console.log(response.output_text);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19import os
from openai import OpenAI
project_id = "your-project-id"
client = OpenAI(
api_key=os.environ["GOOGLE_CLOUD_ACCESS_TOKEN"],
base_url=(
f"https://aiplatform.googleapis.com/v1/projects/{project_id}"
"/locations/global/publishers/openai/v1"
),
)
response = client.responses.create(
model="gpt-6-luna",
input="Write a one-sentence bedtime story about a unicorn.",
store=False,
)
print(response.output_text)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32package main
import (
"context"
"fmt"
"os"
"github.com/openai/openai-go/v3"
"github.com/openai/openai-go/v3/option"
"github.com/openai/openai-go/v3/responses"
)
func main() {
ctx := context.Background()
projectID := "your-project-id"
client := openai.NewClient(
option.WithAPIKey(os.Getenv("GOOGLE_CLOUD_ACCESS_TOKEN")),
option.WithBaseURL("https://aiplatform.googleapis.com/v1/projects/"+projectID+"/locations/global/publishers/openai/v1"),
)
response, err := client.Responses.New(ctx, responses.ResponseNewParams{
Model: "gpt-6-luna",
Input: responses.ResponseNewParamsInputUnion{
OfString: openai.String("Write a one-sentence bedtime story about a unicorn."),
},
Store: openai.Bool(false),
})
if err != nil {
panic(err)
}
fmt.Println(response.OutputText())
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.responses.ResponseCreateParams;
import java.util.stream.Collectors;
public final class GoogleCloudCreateResponseFromEnvironment {
private GoogleCloudCreateResponseFromEnvironment() {}
public static void main(String[] args) {
String accessToken = System.getenv("GOOGLE_CLOUD_ACCESS_TOKEN");
if (accessToken == null || accessToken.isBlank()) {
throw new IllegalArgumentException("Set GOOGLE_CLOUD_ACCESS_TOKEN");
}
// Replace this illustrative value with your approved Google Cloud project ID.
String projectId = "your-project-id";
OpenAIClient client =
OpenAIOkHttpClient.builder()
.apiKey(accessToken)
.baseUrl(
"https://aiplatform.googleapis.com/v1/projects/"
+ projectId
+ "/locations/global/publishers/openai/v1")
.build();
try {
var response =
client
.responses()
.create(
ResponseCreateParams.builder()
.model("gpt-6-luna")
.input("Write a one-sentence bedtime story about a unicorn.")
.store(false)
.build());
String text =
response.output().stream()
.flatMap(item -> item.message().stream())
.flatMap(message -> message.content().stream())
.flatMap(content -> content.outputText().stream())
.map(outputText -> outputText.text())
.collect(Collectors.joining());
System.out.println(text);
} finally {
client.close();
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50using System;
using System.ClientModel;
using System.Text;
using System.Threading.Tasks;
using OpenAI.Responses;
#pragma warning disable OPENAI001
string? accessToken = Environment.GetEnvironmentVariable("GOOGLE_CLOUD_ACCESS_TOKEN");
if (string.IsNullOrWhiteSpace(accessToken))
{
throw new InvalidOperationException("Set GOOGLE_CLOUD_ACCESS_TOKEN");
}
// Replace this illustrative value with your approved Google Cloud project ID.
string projectId = "your-project-id";
ResponsesClient client = new(
new ApiKeyCredential(accessToken),
new ResponsesClientOptions
{
Endpoint = new Uri(
$"https://aiplatform.googleapis.com/v1/projects/{projectId}/locations/global/publishers/openai/v1"
)
}
);
CreateResponseOptions options = new()
{
Model = "gpt-6-luna",
StoredOutputEnabled = false
};
options.InputItems.Add(
ResponseItem.CreateUserMessageItem("Write a one-sentence bedtime story about a unicorn.")
);
ResponseResult response = await client.CreateResponseAsync(options);
StringBuilder text = new();
foreach (ResponseItem item in response.OutputItems)
{
if (item is MessageResponseItem message)
{
foreach (ResponseContentPart content in message.Content)
{
if (content.Kind == ResponseContentPartKind.OutputText)
{
text.Append(content.Text);
}
}
}
}
Console.WriteLine(text.ToString());
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18require "openai"
access_token = ENV.fetch("GOOGLE_CLOUD_ACCESS_TOKEN")
raise ArgumentError, "GOOGLE_CLOUD_ACCESS_TOKEN must not be blank" if access_token.strip.empty?
# Replace this illustrative value with your approved Google Cloud project ID.
project_id = "your-project-id"
client = OpenAI::Client.new(
api_key: access_token,
base_url: "https://aiplatform.googleapis.com/v1/projects/#{project_id}/locations/global/publishers/openai/v1"
)
response = client.responses.create(
model: "gpt-6-luna",
input: "Write a one-sentence bedtime story about a unicorn.",
store: false
)
puts response.output_text
To get access tokens through Google’s authentication library instead of exporting them in your terminal, follow Google’s getting-started guide, which explains how to use Application Default Credentials (ADC) and troubleshoot API errors.
The table compares feature support on Google Cloud with the first-party OpenAI API.
| Capability | OpenAI API | Google Cloud |
|---|
API requests |
|---|
| Text generation | Available | Available |
| Streaming responses over HTTP (SSE) | Available | Available |
| Responses API endpoint | Available | Available |
| Response token usage | Available | Available |
| Input token count endpoint | Available | Not available |
| Realtime WebSocket connections | Available | Not available |
| Background requests | Available | Not available |
| Background stream resume | Available | Not available |
| Chat Completions API | Available | Not available |
| Batch processing | Available | Not available |
Output and reasoning |
|---|
| Structured outputs with JSON Schema | Available | Available |
| JSON mode | Available | Available |
| Reasoning effort | Available | Available |
| Encrypted reasoning | Available | Available |
| Reasoning summaries | Available | Available |
Tools and integrations |
|---|
| Client-side function calling | Available | Available |
| Parallel tool calls | Available | Available |
| Structured function arguments | Available | Available |
| Custom tools | Available | Available with freeform input or regex constraints |
| Client-side tool search | Available | Available |
| Client-run MCP and namespaced tools | Available | Available |
| Client-side shell tool | Available | Available |
| Hosted web search | Available | Not available |
| Hosted file search and vector stores | Available | Not available |
| Hosted code execution | Available | Not available |
| Server-side remote MCP | Available | Not available |
Documents and media |
|---|
| PDF text extraction | Available | Available |
| Inline image input | Available | Available |
| Image generation | Available | Not available |
Conversation state |
|---|
| Saved conversation continuation | Available | Available |
| Stateless conversation continuation | Available | Available |
| Conversation compaction | Available | Available |
| Explicit prompt-cache controls | Available | Available |
Your prompts and responses are not used to train OpenAI models. Default retention is up to 30 days.
If you require Zero Data Retention (ZDR), contact your OpenAI or Google Cloud representative during onboarding and wait for confirmation of support. Setting store: false on a request does not enable ZDR.