Sorry to bother everyone about this but I’ve spent several hours on this and can’t figure it out.
I’m trying to call one of the Lambda gen AI models (doesn’t matter which one) from the API and I keep getting timed out. This happens no matter which model I try to call. It also happens if I replace the API key with “foo”. What am I doing wrong? Code is below.
from openai import OpenAI
import os
client = OpenAI(
base_url="https://api.lambda.ai/v1",
api_key="foo"
)
print("--- Connecting to Lambda to find models... ---")
try:
models = client.models.list()
first_model_id = models.data[0].id
print(f"SUCCESS! Found {len(models.data)} models.") # this code never runs
print(f"We will use this model: {first_model_id}")
print("\n--- Sending Prompt... ---")
response = client.chat.completions.create(
model=first_model_id,
messages=[
{"role": "user", "content": "Explain quantum physics in one sentence."}
],
temperature=0.7,
)
print("\nRESPONSE:")
print(response.choices[0].message.content)
except Exception as e:
print(f"Error: {e}")