const portkey = new Portkey({ apiKey: PORTKEY_API_KEY, config: { strategy: { mode: 'fallback' }, targets: [ { promptID: 'pp-test-811461' }, { promptID: 'pp-l-i-ef463c' } ] } });
const response = await portkey.prompts.completions.create({ variables: { city: 'Hyderabad', name: 'Nobita' } }); console.log(response.choices);
promptID
to prompt_id
. I often come across the following errror:BadRequestError: Following prompt_id are not valid: undefined
prompt_id
in the Config builder should work. The prompts.completions.create
method you've shared is also correct! Is it failing for you?prompts.completions.create
const result = await portkey.prompts.completions.create({
promptID:"<your_prompt_id>",
variables:{
<variable_1>: "<value_1>"
},
})
PromptID
is passed with valid argument. For example, just mentioning dummy_prompt_id
or null
do throw BadRequestError.PromptID
, when valid is passed, the gateway configs take precedence even if original PromptID is not part of the gateway configs.