use serde_json::json;use valyu::ContentsRequest;// Auto AI summarylet req = ContentsRequest::new(urls.clone()) .with_summary(true) .with_response_length("medium");// Custom summary instructionlet req = ContentsRequest::new(urls.clone()) .with_summary_instructions("Summarize the main trends in 3 bullet points") .with_extract_effort("high");// Structured extraction - pass a JSON schema, get back structured fieldslet schema = json!({ "type": "object", "properties": { "company_name": {"type": "string"}, "industry": {"type": "string"}, "founded_year": {"type": "number"} }, "required": ["company_name"]});let req = ContentsRequest::new(vec!["https://en.wikipedia.org/wiki/OpenAI".to_string()]) .with_summary_schema(schema) .with_extract_effort("high");let response = client.contents(&req).await?;
Use with_extract_effort("high") for JS-heavy pages, and with_response_length ("short" 25k, "medium" 50k, "large" 100k, "max") or with_custom_response_length(i32) to control content per URL.
For arXiv, PubMed Central, bioRxiv, medRxiv, and ChemRxiv papers, Valyu serves clean processed markdown (with figures and equations) from its academic index when your plan covers the source - otherwise it uses the live crawler. Pass the paper URL (a /pdf/ arXiv link or a DOI works best) or bare id. See Academic Papers.