https://www.boundaryml.com logo
[RESOLVED] Running tests in BAML playground return...
# help
s
When I try running BAML playground unit tests in Cursor IDE, I get an invalid authentication error. However, I can't seem to figure out why. Any help appreciated!
Copy code
InvalidAuthentication (401) Request failed with status code: 401 Unauthorized, 
{"type":"error","error":{"type":"authentication_error","message":"invalid x-api-key"},"request_id":"req_011CVS9mZX2HWyWvLd2FDx4D"}

Request options: {"model":"claude-sonnet-4-5-20250929","max_tokens":4096}
Here is my BAML client
Copy code
// Coding agent for modifying React Native App.js files

// Output structure for the coding agent
class CodeGenerationResult {
  code string
}

// Client for Claude Sonnet 3.5
client<llm> ClaudeSonnet {
  provider anthropic
  options {
    model "claude-sonnet-4-5-20250929"
    api_key env.ANTHROPIC_API_KEY
  }
}

// Function to generate/modify App.js code based on user prompt
function GenerateAppJsCode(
  userPrompt: string,
  currentAppJs: string
) -> CodeGenerationResult {
  client ClaudeSonnet
  prompt #"
You are a React Native/Expo coding assistant. Your task is to modify the App.js file in a React Native Expo application based on user requirements.

Current App.js code:
```javascript
{{ currentAppJs }}
User requirements: {{ userPrompt }} Please provide the complete updated App.js code in the required JSON format: "# } test create_simple_app { functions [GenerateAppJsCode] args { userPrompt "Create a simple React Native app with a button that says 'Hello World'" currentAppJs #" import { StatusBar } from 'expo-status-bar'; import { StyleSheet, Text, View } from 'react-native'; export default function App() { return ( Open up App.js to start working on your app! ); } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#fff', alignItems: 'center', justifyContent: 'center', }, }); "# } } ```
Oh never mind, I was naively assuming playground picks up from env variables. I explicitly set it and now it's working!
2 Views