https://www.boundaryml.com logo
🟡 Syntax for Function in BAML
# questions
i
Is it possible to do something like this in BAML? if yes what's the correct syntax?
Copy code
function AnalyzeResumeWithLinks(resume: image | pdf, links_json: string, ...args) -> ResumeAnalysis {
  client Gemini2_5FlashLite
  params {
    temperature args["temperature"] ? 0.2
    max_tokens args["max_tokens"] ? 1500
  }
  prompt #"
g
We don't allow anything like kwargs in BAML. What extra variable args would you want to pass in?
i
Correct me if I am wrong, I am treating Client as a provider and assuming that one provider once setup, can be used in multiple calls. And if I am making multiple calls, I would like to have control over each type of calls and set their temp, max_tokens, top_k, top_p etc...
a
do you want each function to have different parameters for that client?
you can use the client registry:
Copy code
@pytest.mark.asyncio
async def test_dynamic_client_with_vertex_json_str_creds():
    cb = baml_py.ClientRegistry()
    cb.add_llm_client(
        "MyClient",
        "vertex-ai",
        {
            "model": "gemini-1.5-pro",
            "location": "us-central1",
            "credentials": os.environ[
                "INTEG_TESTS_GOOGLE_APPLICATION_CREDENTIALS_CONTENT"
            ],
        },
    )
    cb.set_primary("MyClient")

    capitol = await b.ExpectFailure(
        baml_options={"client_registry": cb},
    )
    assert_that(capitol.lower()).contains("london")
and modify that at will for each client
i
Got it! That's what I wanted. Thanks
z
Is it possible to programmatically get the list of registered clients? For instance, if I have the following clients defined:
Copy code
client<llm> GPT5 {
  provider "openai"
  options {
    model "gpt-5"
    api_key env.OPENAI_API_KEY
  }
}

client<llm> Gemini25Pro {
  provider google-ai
  retry_policy ExpBackoffRetryPolicy
  options {
    model "gemini-2.5-pro"
    api_key env.GEMINI_API_KEY
    generationConfig {
      temperature 0.0
      thinkingConfig {
        thinkingBudget 4000
      }
    }
  }
}
I'd be looking for a variable or function that would return
["GPT5", "Gemini25Pro"]
Does this exist, or is there a roundabout way to generate such a list at runtime?
g
Right now you can use ClientRegistry to modify clients, not read them out, but we have been talking about updating it so you can also inspect the clients you defined. I'll raise this with the team, that'll bump the priority.