You can query the API using the same methods regardless of which installation
method you used. How you query the API depends on whether or not you have
configured a public endpoint. If your endpoint is not public, you will need
to determine how to expose the API yourself. There are many options for doing
this, including creating an
Ingress if
your cluster supports it, publishing the created service,
running Istio, and so on.
The steps outlined below walk you through querying an endpoint. There are two
methods:
Query the endpoint from within your cluster (no public IP required).
Query a public IP.
Query the internal DNS name (no public IP required)
This example runs a query from within the cluster using the Domain Name Service
(DNS) name assigned to the service: $NAME.$NAMESPACE, such as speech.speech.
You can either set the environment variables or replace them with actual value
in the commands.
Create a new job within the cluster to query the API from. If this job
already exists in the cluster, you should remove it first.
kubectl logs -n $NAMESPACE --follow $(kubectl get po -n $NAMESPACE -l
app=query -o=jsonpath='{.items[0].metadata.name}') -c entrypoint
Query a public IP
If you installed Istio in your cluster, make sure that you have Istio Ingress
Gateway running with a public IP. If you haven't installed Istio you can set
the value for $PUBLIC_IP. Once this is completed, you can submit transcription
queries to a public endpoint.
If you have Istio installed, follow the
instructions
to get the Ingress public IP and set it to PUBLIC_IP.
If you don't have Istio installed, validate that the IP address was bound. It
should appear under EXTERNAL-IP below. If it doesn't appear after a few
minutes, navigate to
your cluster in the console
for troubleshooting.
kubectl get service $NAME --namespace $NAMESPACE
Copy the onprem_client binary from the docker image:
kubectl cp -n $NAMESPACE $(kubectl get pod -n $NAMESPACE -l
app.kubernetes.io/name=$NAME -o=jsonpath='{.items[0].metadata.name}'
):/bin/onprem_client ./onprem_client
kubectl cp -n $NAMESPACE $(kubectl get pod -n $NAMESPACE -l
app.kubernetes.io/name=$NAME -o=jsonpath='{.items[0].metadata.name}'
):/usr/grte.tar ./grte.tar
sudo tar -xvf grte.tar -C /
chmod a+x ./onprem_client
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Quickstart: Query the API\n\n| **Private feature** \n| This product is a private feature. The documentation is publicly available but you must [contact Google](https://cloud.google.com/contact) for full access.\n\nPrerequisites\n-------------\n\n1. Complete all required steps in the [before you begin](/speech-to-text/priv/docs/before-you-begin) quickstart.\n2. [Deploy the API](/speech-to-text/priv/docs/deploy).\n\nOverview\n--------\n\nYou can query the API using the same methods regardless of which installation\nmethod you used. How you query the API depends on whether or not you have\nconfigured a public endpoint. If your endpoint is **not public** , you will need\nto determine how to expose the API yourself. There are many options for doing\nthis, including creating an\n[Ingress](https://kubernetes.io/docs/concepts/services-networking/ingress/) if\nyour cluster supports it, [publishing the created service](https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types),\nrunning [Istio](https://istio.io/), and so on.\n\nThe steps outlined below walk you through querying an endpoint. There are two\nmethods:\n\n1. Query the endpoint from within your cluster (no public IP required).\n2. Query a public IP.\n\nQuery the internal DNS name (no public IP required)\n---------------------------------------------------\n\nThis example runs a query from within the cluster using the Domain Name Service\n(DNS) name assigned to the service: `$NAME.$NAMESPACE`, such as `speech.speech.`\nYou can either set the environment variables or replace them with actual value\nin the commands.\n\n1. Create a new job within the cluster to query the API from. If this job\n already exists in the cluster, you should remove it first.\n\n kubectl delete jobs.batch -n $NAMESPACE query-api\n\n echo \"apiVersion: batch/v1\n kind: Job\n metadata:\n name: query-api\n namespace: $NAMESPACE\n spec:\n template:\n metadata:\n annotations:\n sidecar.istio.io/inject: 'false'\n labels:\n app: query\n spec:\n containers:\n - name: entrypoint\n image: gcr.io/cloud-marketplace/speech-onprem/speech-to-text-on-prem:$VERSION\n command: [\"/bin/sh\", \"-c\"]\n args:\n - curl https://raw.githubusercontent.com/GoogleCloudPlatform/python-docs-samples/master/speech/snippets/resources/commercial_mono.wav --output /tmp/audio.wav;\n /bin/onprem_client --address=$NAME.$NAMESPACE:443 --file_paths /tmp/audio.wav\n restartPolicy: Never\n \" | kubectl apply -f -\n\n2. Check the logs to see the transcript:\n\n kubectl logs -n $NAMESPACE --follow $(kubectl get po -n $NAMESPACE -l\n app=query -o=jsonpath='{.items[0].metadata.name}') -c entrypoint\n\nQuery a public IP\n-----------------\n\nIf you installed Istio in your cluster, make sure that you have Istio Ingress\nGateway running with a public IP. If you haven't installed Istio you can set\nthe value for `$PUBLIC_IP`. Once this is completed, you can submit transcription\nqueries to a public endpoint.\n\n1. If you have Istio installed, follow the\n [instructions](https://istio.io/latest/docs/tasks/traffic-management/ingress/ingress-control/#determining-the-ingress-ip-and-ports)\n to get the Ingress public IP and set it to `PUBLIC_IP`.\n\n2. If you don't have Istio installed, validate that the IP address was bound. It\n should appear under `EXTERNAL-IP` below. If it doesn't appear after a few\n minutes, navigate to\n [your cluster in the console](https://console.cloud.google.com/kubernetes/list)\n for troubleshooting.\n\n kubectl get service $NAME --namespace $NAMESPACE\n\n 1. Copy the `onprem_client` binary from the docker image:\n\n kubectl cp -n $NAMESPACE $(kubectl get pod -n $NAMESPACE -l\n app.kubernetes.io/name=$NAME -o=jsonpath='{.items[0].metadata.name}'\n ):/bin/onprem_client ./onprem_client\n\n kubectl cp -n $NAMESPACE $(kubectl get pod -n $NAMESPACE -l\n app.kubernetes.io/name=$NAME -o=jsonpath='{.items[0].metadata.name}'\n ):/usr/grte.tar ./grte.tar\n\n sudo tar -xvf grte.tar -C /\n\n chmod a+x ./onprem_client\n\n 2. Use the `onprem_client` binary to submit a query:\n\n ./onprem_client --address ${PUBLIC_IP}:443\n --file_paths /path/to/audio.wav\n\n| **Note:** For languages other than en-us, an extra parameter is needed, such as --language_code yue-Hant-HK.\n\nWhat's next\n-----------\n\nLearn how to [send a transcription request](/speech-to-text/priv/docs/transcribe)\nto the Speech-to-Text On-Prem API."]]