SAN FRANCISCO (AP) _ The new $135-million main library, scheduled to open in 1995, will include one of the most ambitious archives ever assembled of materials on lesbian and gay history, literature and culture.

The San Francisco Main Library was damaged in the 1989 earthquake. As planning for a new building began, the library commission looked for a significant community need that other libraries were not addressing, said commissioner Steve Coulter.

There are dozens of small gay and lesbian archives archives at universities and elsewhere across the country. But the new library's Gay and Lesbian Center is expected to include hundreds of thousands of items and become the focal point of a major research center, sponsoring exhibits, conferences and readings.

The library plans to index almost 200 gay and lesbian periodicals. The collection also will have a film and video component.

Best-selling author Randy Shilts has promised to donate tens of thousands of pages of research material from his three books, including this year's ''Conduct Unbecoming,'' about gay men and lesbians in the military.

San Francisco filmmakers Rob Epstein (''The Times of Harvey Milk,'' ''Common Threads: Stories From the Quilt'') and Peter Adair (''Word Is Out'') have donated dozens of boxes of film clips, stills and other materials from their documentaries.