invalid JSON schema with python client

I have been unable to send a request with a prompt and schema. I get OK results when I write a simplified schema within the prompt, however passing the class itself would be ideal per the documentation. Code is as follows:
class SecondaryAsset(BaseModel):
"""
Model for a secondary asset.
"""

name: str
url: str
start_time: Optional[datetime | str]
end_time: Optional[datetime | str]
location: Optional[str] = None
short_description: str = None
long_description: str

app.extract(
[source.source_url],
prompt=selected_prompt, # stored in prompts.py
schema=SecondaryAsset.model_json_schema(),
)
class SecondaryAsset(BaseModel):
"""
Model for a secondary asset.
"""

name: str
url: str
start_time: Optional[datetime | str]
end_time: Optional[datetime | str]
location: Optional[str] = None
short_description: str = None
long_description: str

app.extract(
[source.source_url],
prompt=selected_prompt, # stored in prompts.py
schema=SecondaryAsset.model_json_schema(),
)
The error I get:
Firecrawl extraction failed: Bad Request: Failed to extract. Bad Request - [{'code': 'custom', 'message': 'Invalid JSON schema.', 'path': ['schema']}]
Firecrawl extraction failed: Bad Request: Failed to extract. Bad Request - [{'code': 'custom', 'message': 'Invalid JSON schema.', 'path': ['schema']}]
2 Replies
micah.stairs
micah.stairs2w ago
I already replied over the support ticket, but for the benefit of others, I think you just need to change start_time and end_time to Optional[str] in your Pydantic model.
nationalmyth
nationalmythOP2w ago
^^ Confirmed this was the fix.

Did you find this page helpful?