Using Gradio API Replica URL's / Issue with --replica

When I rebuild a T4 GPU docker my URL keeps changing to indicate the replica. E.g.:
https://awacke1-speech-recognition-canary-nvidiat4.hf.space/--replicas/y35z0/

When I call the gradio app as API I would like to make the consumer impervious to a change in URL.

Will it work if I don’t include replica in the URL. e.g.
https://awacke1-speech-recognition-canary-nvidiat4.hf.space/ ?

My calling code uses the URL as follows:
def transcribeWavtoTxt(filename):
from gradio_client import Client
with open(filename, “rb”) as f:
data = f.read()
url=‘https://awacke1-speech-recognition-canary-nvidiat4.hf.space/--replicas/4j9xb/’
client = Client(url)

    #old URL from last build ---      client = Client("https://awacke1-speech-recognition-canary-nvidiat4.hf.space/--replicas/0wdf4/")
    result = client.predict(
            filename,
            "English",	# Literal['English', 'Spanish', 'French', 'German']  in 'Input audio is spoken in:' Dropdown component
            "English",	# Literal['English', 'Spanish', 'French', 'German']  in 'Transcribe in language:' Dropdown component
            True,	# bool  in 'Punctuation & Capitalization in transcript?' Checkbox component
            api_name="/transcribe"
    )
    return result

Hello @awacke1, yes, you’re correct; there’s no need to be concerned with the replica suffix at the end of the URL, as your internal proxy will handle that aspect effectively.

2 Likes

You’re the best. Thankyou sir for quick response. Much appreciated!

–Aaron

2 Likes
from gradio_client import Client

# Connect to the Gradio client
client = Client("black-forest-labs/FLUX.1-schnell")

# Call the inference endpoint
result = client.predict(
    "/infer",  # Endpoint
    { 
        "prompt": "Hello!!",  # Input parameters
        "seed": 0,
        "randomize_seed": True,
        "width": 256,
        "height": 256,
        "num_inference_steps": 1
    }
)

result

this is the code and the output of code is

Loaded as API: https://black-forest-labs-flux-1-schnell.hf.space ✔
('/tmp/gradio/489613c1bc4fe4fcf1b0e5a1d10b5977449d157f9eae4ccd9b8117765eabca12/image.webp',
 653764749)

after that i tried to get the actual generated image and it’s not showing

the full url look like

https://black-forest-labs-flux-1-schnell.hf.space/file=/tmp/gradio/489613c1bc4fe4fcf1b0e5a1d10b5977449d157f9eae4ccd9b8117765eabca12/image.webp

{"detail":"File not found: /tmp/gradio/489613c1bc4fe4fcf1b0e5a1d10b5977449d157f9eae4ccd9b8117765eabca12/image.webp."}

1 Like