Proxy Integration

1

Create an account + Generate an API Key

Log into qualifire or create an account. Once you have an account, you can generate an API key.

2

Set API keys as environment variables

export QUALIFIRE_API_KEY=<your API key>
3

Install necessary packages

Ensure you have the necessary packages installed in your Javascript project:

  pip install --upgrade google-cloud-aiplatform
  gcloud auth application-default login
4

Import VertexAI and configure the client

import vertexai
from vertexai.generative_models import GenerativeModel

LOCATION = "us-central1"


vertexai.init(
  project="qualifire-prod",
  location=LOCATION,
  api_transport="rest",
  api_endpoint="https://proxy.qualifire.ai/api/providers/google",
  request_metadata=[
      ("X-Qualifire-Base-Url", f"https://{LOCATION}-aiplatform.googleapis.com"),
      ("X-Qualifire-API-Key", "<your API key>"),
  ],
) 

model = GenerativeModel(
  "gemini-1.5-flash-002",
)

5

Call the API

def generate():
    responses = model.generate_content(
        ["""tell me a joke about cats"""],
        generation_config=generation_config,
        stream=True,
    )

    for response in responses:
        print(response.text, end="")

generation_config = {
      "max_output_tokens": 8192,
      "temperature": 1,
      "top_p": 0.95,
}

generate()