```javascript
import { Groq } from "groq-sdk";
import { z } from "zod"; 

const client = new Groq();

// Define a schema for validation
const MovieSchema = z.object({
  title: z.string(),
  year: z.number().int(),
  director: z.string(),
  genre: z.array(z.string()),
  runtime_minutes: z.number().int(),
  rating: z.number().min(1).max(10),
  box_office_millions: z.number(),
  cast: z.array(
    z.object({
      actor: z.string(),
      character: z.string()
    })
  )
});

type Movie = z.infer<typeof MovieSchema>;

// Example of a poorly designed prompt
const poorPrompt = `
Give me information about a movie in JSON format.
`;

// Example of a well-designed prompt
const effectivePrompt = `
You are a movie database API. Return information about a movie with the following 
JSON structure:

{
  "title": "string",
  "year": number,
  "director": "string",
  "genre": ["string"],
  "runtime_minutes": number,
  "rating": number (1-10 scale),
  "box_office_millions": number,
  "cast": [
    {
      "actor": "string",
      "character": "string"
    }
  ]
}

The response must:
1. Include ALL fields shown above
2. Use only the exact field names shown
3. Follow the exact data types specified
4. Contain ONLY the JSON object and nothing else

IMPORTANT: Do not include any explanatory text, markdown formatting, or code blocks.
`;

// Function to run the completion and display results
async function getMovieData(prompt: string, title = "Example"): Promise<Movie | null> {
  console.log(`\n--- ${title} ---`);
  
  try {
    const completion = await client.chat.completions.create({
      model: "llama-3.3-70b-versatile",
      response_format: { type: "json_object" },
      messages: [
        { role: "system", content: prompt },
        { role: "user", content: "Tell me about The Matrix" },
      ],
    });
    
    const responseContent = completion.choices[0].message.content;
    console.log("Raw response:");
    console.log(responseContent);
    
    // Try to parse as JSON
    try {
      const movieData = JSON.parse(responseContent || "");
      console.log("\nSuccessfully parsed as JSON!");
      
      // Validate against schema
      try {
        const validatedMovie = MovieSchema.parse(movieData);
        console.log("All expected fields present and valid!");
        return validatedMovie;
      } catch (validationError) {
        if (validationError instanceof z.ZodError) {
          console.log("Schema validation failed:");
          console.log(validationError.errors.map(e => `- ${e.path.join('.')}: ${e.message}`).join('\n'));
        }
        return null;
      }
    } catch (syntaxError) {
      console.log("\nFailed to parse as JSON. Response is not valid JSON.");
      return null;
    }
  } catch (error) {
    console.error("Error:", error);
    return null;
  }
}

// Compare the results of both prompts
async function comparePrompts() {
  await getMovieData(poorPrompt, "Poor Prompt Example");
  await getMovieData(effectivePrompt, "Effective Prompt Example");
}

// Run the examples
comparePrompts();
```

---

## pip install pydantic